From 76fcf035ba5b772846433f7dd7324cfa6e767fd6 Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Sun, 26 Feb 2017 16:30:18 +0100 Subject: [PATCH] Sda1 WS 2016/17 --- Klausuren/Sda1/2016Winter/Exam/.gitignore | 4 + .../Sda1/2016Winter/Exam/Schema/company.xsd | 6 + .../2016Winter/Exam/Schema/sampledata.xml | 39 +++++ .../Exam/SchemaTest/0100valid_minimum.xml | 15 ++ .../SchemaTest/0115invalid_shortWithSpace.xml | 19 +++ .../SchemaTest/0120invalid_duplicateShort.xml | 23 +++ .../Exam/SchemaTest/0125invalid_noShort.xml | 19 +++ .../0130invalid_shortZeroLength.xml | 19 +++ .../SchemaTest/0140invalid_noDepartment.xml | 15 ++ .../Exam/SchemaTest/0145invalid_noName.xml | 20 +++ .../SchemaTest/0150invalid_duplicateName.xml | 15 ++ .../Exam/SchemaTest/0200valid_nesting.xml | 27 +++ .../0210invalid_nestingDuplicateShort.xml | 27 +++ .../Exam/SchemaTest/0300valid_minEmployee.xml | 19 +++ .../SchemaTest/0305invalid_NoDepartment.xml | 24 +++ .../Exam/SchemaTest/0310invalid_NoSsn.xml | 24 +++ .../SchemaTest/0315invalid_NoCommonName.xml | 22 +++ .../0325invalid_duplicateCommonName.xml | 24 +++ .../SchemaTest/0400valid_multipleEmployee.xml | 22 +++ .../SchemaTest/0410invalid_duplicateSsn.xml | 27 +++ Klausuren/Sda1/2016Winter/Exam/Sql/sample.sql | 34 ++++ Klausuren/Sda1/2016Winter/Exam/pom.xml | 158 ++++++++++++++++++ .../exam/dataexport/model/Department.java | 68 ++++++++ .../mi/sda1/exam/jdbcexport/EmployeeInfo.java | 33 ++++ .../mi/sda1/exam/jpaexport/EmployeeInfo.java | 49 ++++++ .../main/resources/META-INF/persistence.xml | 96 +++++++++++ .../Exam/src/main/resources/log4j2.xml | 21 +++ .../mi/sda1/exam/xsd/test/SchemaTest.java | 26 +++ Klausuren/Sda1/2016Winter/Solution/.gitignore | 4 + .../Sda1/2016Winter/Solution/Doc/ex1.xhtml | 148 ++++++++++++++++ .../Sda1/2016Winter/Solution/Doc/ex2.xml | 43 +++++ .../Sda1/2016Winter/Solution/Doc/ex3.xml | 84 ++++++++++ .../2016Winter/Solution/Doc/movie2html.xhtml | 103 ++++++++++++ .../2016Winter/Solution/Doc/movieSql.xhtml | 45 +++++ .../2016Winter/Solution/Schema/company.xsd | 61 +++++++ .../2016Winter/Solution/Schema/sampledata.xml | 39 +++++ .../Solution/SchemaTest/0100valid_minimum.xml | 15 ++ .../SchemaTest/0115invalid_shortWithSpace.xml | 19 +++ .../SchemaTest/0120invalid_duplicateShort.xml | 23 +++ .../SchemaTest/0125invalid_noShort.xml | 19 +++ .../0130invalid_shortZeroLength.xml | 19 +++ .../SchemaTest/0140invalid_noDepartment.xml | 15 ++ .../SchemaTest/0145invalid_noName.xml | 20 +++ .../SchemaTest/0150invalid_duplicateName.xml | 15 ++ .../Solution/SchemaTest/0200valid_nesting.xml | 27 +++ .../0210invalid_nestingDuplicateShort.xml | 27 +++ .../SchemaTest/0300valid_minEmployee.xml | 19 +++ .../SchemaTest/0305invalid_NoDepartment.xml | 24 +++ .../Solution/SchemaTest/0310invalid_NoSsn.xml | 24 +++ .../SchemaTest/0315invalid_NoCommonName.xml | 22 +++ .../0325invalid_duplicateCommonName.xml | 24 +++ .../SchemaTest/0400valid_multipleEmployee.xml | 22 +++ .../SchemaTest/0410invalid_duplicateSsn.xml | 27 +++ .../Sda1/2016Winter/Solution/Sql/sample.sql | 34 ++++ Klausuren/Sda1/2016Winter/Solution/pom.xml | 158 ++++++++++++++++++ .../mi/sda1/exam/dataexport/EmployeeInfo.java | 65 +++++++ .../exam/dataexport/model/Department.java | 68 ++++++++ .../sda1/exam/dataexport/model/Employee.java | 63 +++++++ .../main/resources/META-INF/persistence.xml | 96 +++++++++++ .../Solution/src/main/resources/log4j2.xml | 21 +++ .../mi/sda1/exam/xsd/test/SchemaTest.java | 26 +++ Klausuren/Sda1/2016Winter/Solution/todo.txt | 6 + Klausuren/Sda1/Papier/113305.tex | 47 ++++++ Klausuren/Sda1/Papier/Code/.gitignore | 4 + Klausuren/Sda1/Papier/Code/Xsd/bingo.xml | 5 + Klausuren/Sda1/Papier/Code/Xsd/test.xsd | 13 ++ Klausuren/Sda1/Papier/Code/jdomException.txt | 8 + Klausuren/Sda1/Papier/Code/pom.xml | 88 ++++++++++ .../src/main/java/papier/klausur/App.java | 44 +++++ .../main/java/papier/klausur/Careless.java | 35 ++++ .../Papier/Code/src/main/resources/log4j2.xml | 21 +++ .../src/test/java/papier/klausur/AppTest.java | 17 ++ Klausuren/Sda1/Papier/bonus.tex | 17 ++ Klausuren/Sda1/Papier/hinweis.tex | 15 ++ Klausuren/Sda1/Papier/jdom.tex | 25 +++ Klausuren/Sda1/Papier/jdomerror.tex | 31 ++++ Klausuren/Sda1/Papier/prepared.tex | 15 ++ Klausuren/Sda1/Papier/xsd.tex | 32 ++++ 78 files changed, 2737 insertions(+) create mode 100644 Klausuren/Sda1/2016Winter/Exam/.gitignore create mode 100644 Klausuren/Sda1/2016Winter/Exam/Schema/company.xsd create mode 100644 Klausuren/Sda1/2016Winter/Exam/Schema/sampledata.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0100valid_minimum.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0115invalid_shortWithSpace.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0120invalid_duplicateShort.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0125invalid_noShort.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0130invalid_shortZeroLength.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0140invalid_noDepartment.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0145invalid_noName.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0150invalid_duplicateName.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0200valid_nesting.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0210invalid_nestingDuplicateShort.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0300valid_minEmployee.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0305invalid_NoDepartment.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0310invalid_NoSsn.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0315invalid_NoCommonName.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0325invalid_duplicateCommonName.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0400valid_multipleEmployee.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/SchemaTest/0410invalid_duplicateSsn.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/Sql/sample.sql create mode 100644 Klausuren/Sda1/2016Winter/Exam/pom.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Department.java create mode 100644 Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/jdbcexport/EmployeeInfo.java create mode 100644 Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/jpaexport/EmployeeInfo.java create mode 100644 Klausuren/Sda1/2016Winter/Exam/src/main/resources/META-INF/persistence.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/src/main/resources/log4j2.xml create mode 100644 Klausuren/Sda1/2016Winter/Exam/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java create mode 100644 Klausuren/Sda1/2016Winter/Solution/.gitignore create mode 100644 Klausuren/Sda1/2016Winter/Solution/Doc/ex1.xhtml create mode 100644 Klausuren/Sda1/2016Winter/Solution/Doc/ex2.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/Doc/ex3.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/Doc/movie2html.xhtml create mode 100644 Klausuren/Sda1/2016Winter/Solution/Doc/movieSql.xhtml create mode 100644 Klausuren/Sda1/2016Winter/Solution/Schema/company.xsd create mode 100644 Klausuren/Sda1/2016Winter/Solution/Schema/sampledata.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0100valid_minimum.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0115invalid_shortWithSpace.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0120invalid_duplicateShort.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0125invalid_noShort.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0130invalid_shortZeroLength.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0140invalid_noDepartment.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0145invalid_noName.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0150invalid_duplicateName.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0200valid_nesting.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0210invalid_nestingDuplicateShort.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0300valid_minEmployee.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0305invalid_NoDepartment.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0310invalid_NoSsn.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0315invalid_NoCommonName.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0325invalid_duplicateCommonName.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0400valid_multipleEmployee.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/SchemaTest/0410invalid_duplicateSsn.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/Sql/sample.sql create mode 100644 Klausuren/Sda1/2016Winter/Solution/pom.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/EmployeeInfo.java create mode 100644 Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Department.java create mode 100644 Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Employee.java create mode 100644 Klausuren/Sda1/2016Winter/Solution/src/main/resources/META-INF/persistence.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/src/main/resources/log4j2.xml create mode 100644 Klausuren/Sda1/2016Winter/Solution/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java create mode 100644 Klausuren/Sda1/2016Winter/Solution/todo.txt create mode 100644 Klausuren/Sda1/Papier/113305.tex create mode 100644 Klausuren/Sda1/Papier/Code/.gitignore create mode 100644 Klausuren/Sda1/Papier/Code/Xsd/bingo.xml create mode 100644 Klausuren/Sda1/Papier/Code/Xsd/test.xsd create mode 100644 Klausuren/Sda1/Papier/Code/jdomException.txt create mode 100644 Klausuren/Sda1/Papier/Code/pom.xml create mode 100644 Klausuren/Sda1/Papier/Code/src/main/java/papier/klausur/App.java create mode 100644 Klausuren/Sda1/Papier/Code/src/main/java/papier/klausur/Careless.java create mode 100644 Klausuren/Sda1/Papier/Code/src/main/resources/log4j2.xml create mode 100644 Klausuren/Sda1/Papier/Code/src/test/java/papier/klausur/AppTest.java create mode 100644 Klausuren/Sda1/Papier/bonus.tex create mode 100644 Klausuren/Sda1/Papier/hinweis.tex create mode 100644 Klausuren/Sda1/Papier/jdom.tex create mode 100644 Klausuren/Sda1/Papier/jdomerror.tex create mode 100644 Klausuren/Sda1/Papier/prepared.tex create mode 100644 Klausuren/Sda1/Papier/xsd.tex diff --git a/Klausuren/Sda1/2016Winter/Exam/.gitignore b/Klausuren/Sda1/2016Winter/Exam/.gitignore new file mode 100644 index 000000000..3498d4a33 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/.gitignore @@ -0,0 +1,4 @@ +/.classpath +/.project +A1.log + diff --git a/Klausuren/Sda1/2016Winter/Exam/Schema/company.xsd b/Klausuren/Sda1/2016Winter/Exam/Schema/company.xsd new file mode 100644 index 000000000..8a6a6a361 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/Schema/company.xsd @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > + + <xs:element name="company"/> <!-- TODO: implement me --> + +</xs:schema> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/Schema/sampledata.xml b/Klausuren/Sda1/2016Winter/Exam/Schema/sampledata.xml new file mode 100644 index 000000000..fae13b2a3 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/Schema/sampledata.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company xsi:noNamespaceSchemaLocation="company.xsd" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + + <departments> + <department short="fs"> + <name>Financial Services</name> + + <department short="cust"> + <name>Customer Relations</name> + + <department short="support"> + <name>Customer Support</name> + </department> + </department> + + <department short="4you"> + <name>Marketing for you</name> + </department> + + </department> + + <department short="dev"> + <name>Development</name> + </department> + + </departments> + + <employees> + <employee ssn="987-65-4320" department="dev"> + <commonName>Sue Baker</commonName> + </employee> + <employee ssn="987-65-4326" department="support"> + <commonName>Jim Smith</commonName> + </employee> + </employees> + +</company> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0100valid_minimum.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0100valid_minimum.xml new file mode 100644 index 000000000..ce221a1c7 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0100valid_minimum.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees/> + +</company> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0115invalid_shortWithSpace.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0115invalid_shortWithSpace.xml new file mode 100644 index 000000000..81e3a6b08 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0115invalid_shortWithSpace.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a b"> <!-- Error: @short must not contain spaces --> + <name>A</name> + </department> + </departments> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0120invalid_duplicateShort.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0120invalid_duplicateShort.xml new file mode 100644 index 000000000..6444aa5bd --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0120invalid_duplicateShort.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="abc"> + <name>A</name> + </department> + + <department short="abc"> <!-- Error: Duplicate @short value "abc" --> + <name>A</name> + </department> + </departments> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0125invalid_noShort.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0125invalid_noShort.xml new file mode 100644 index 000000000..e5b79eb8d --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0125invalid_noShort.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department > <!-- Error: @short attribute undefined --> + <name>A</name> + </department> + </departments> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0130invalid_shortZeroLength.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0130invalid_shortZeroLength.xml new file mode 100644 index 000000000..9794632c8 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0130invalid_shortZeroLength.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short=""> <!-- Error: @short has zero length --> + <name>A</name> + </department> + </departments> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0140invalid_noDepartment.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0140invalid_noDepartment.xml new file mode 100644 index 000000000..1f7e8447f --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0140invalid_noDepartment.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments/> <!-- Error: Need at least one <department> --> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0145invalid_noName.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0145invalid_noName.xml new file mode 100644 index 000000000..8456f73c1 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0145invalid_noName.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + <name>B</name> <!-- Error: <name> must appear exactly once --> + </department> + </departments> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0150invalid_duplicateName.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0150invalid_duplicateName.xml new file mode 100644 index 000000000..c3e9279f4 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0150invalid_duplicateName.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments/> <!-- Error: Need at least one department --> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0200valid_nesting.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0200valid_nesting.xml new file mode 100644 index 000000000..25c5bd7d0 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0200valid_nesting.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + <department short="b"> + <name>B</name> + <department short="c"> + <name>C</name> + <department short="d"> + <name>D</name> + </department> + <department short="e"> + <name>E</name> + </department> + </department> + </department> + </department> + </departments> + + <employees/> + +</company> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0210invalid_nestingDuplicateShort.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0210invalid_nestingDuplicateShort.xml new file mode 100644 index 000000000..01da54ae9 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0210invalid_nestingDuplicateShort.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + <department short="abc"> + <name>B</name> + <department short="abc"> <!-- Error: duplicate @short value "abc" --> + <name>C</name> + <department short="d"> + <name>D</name> + </department> + </department> + </department> + </department> + </departments> + <employees/> +</company> + +<?xmlTest + points = "2" + expectedToBeValid = "false" + preconditionValid = "0200valid_nesting.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0300valid_minEmployee.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0300valid_minEmployee.xml new file mode 100644 index 000000000..ef0e10971 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0300valid_minEmployee.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="123-33-2213" department="a"> + <commonName>Pam Baker</commonName> + </employee> + </employees> + +</company> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0305invalid_NoDepartment.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0305invalid_NoDepartment.xml new file mode 100644 index 000000000..92f46bcb2 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0305invalid_NoDepartment.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="123-33-2213"> <!--Error: missing department attribute --> + <commonName>Pam Baker</commonName> + </employee> + </employees> + +</company> + +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0300valid_minEmployee.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0310invalid_NoSsn.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0310invalid_NoSsn.xml new file mode 100644 index 000000000..99f9ba3e5 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0310invalid_NoSsn.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee department="a"> <!--Error: missing ssn attribute --> + <commonName>Pam Baker</commonName> + </employee> + </employees> + +</company> + +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0300valid_minEmployee.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0315invalid_NoCommonName.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0315invalid_NoCommonName.xml new file mode 100644 index 000000000..16bc7f587 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0315invalid_NoCommonName.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="213-55-3213" department="a"/> <!--Error: missing <commonName> --> + </employees> + +</company> + +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0300valid_minEmployee.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0325invalid_duplicateCommonName.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0325invalid_duplicateCommonName.xml new file mode 100644 index 000000000..a34c36329 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0325invalid_duplicateCommonName.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="123-33-2213" department="a"> + <commonName>Pam Baker</commonName> + <commonName>Tim Berners Lee</commonName> + </employee> + </employees> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0300valid_minEmployee.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0400valid_multipleEmployee.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0400valid_multipleEmployee.xml new file mode 100644 index 000000000..d87bf34ce --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0400valid_multipleEmployee.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="123-33-2213" department="a"> + <commonName>Pam Baker</commonName> + </employee> + <employee ssn="123-33-2215" department="a"> + <commonName>Pam Baker</commonName> + </employee> + </employees> + +</company> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0410invalid_duplicateSsn.xml b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0410invalid_duplicateSsn.xml new file mode 100644 index 000000000..c7e4a115b --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/SchemaTest/0410invalid_duplicateSsn.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="123-33-2213" department="a"> + <commonName>Pam Baker</commonName> + </employee> + <employee ssn="123-33-2213" department="a"> <!--Error: Duplicate ssn --> + <commonName>Pam Baker</commonName> + </employee> + </employees> + +</company> + +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0400valid_multipleEmployee.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/Sql/sample.sql b/Klausuren/Sda1/2016Winter/Exam/Sql/sample.sql new file mode 100644 index 000000000..4cb56af4b --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/Sql/sample.sql @@ -0,0 +1,34 @@ +DROP TABLE IF EXISTS Employee; +DROP TABLE IF EXISTS Department; + +CREATE TABLE Department( + + shortName CHAR(10) NOT NULL + ,PRIMARY KEY(shortName) + + ,name VARCHAR(30) NOT NULL + ,parent CHAR(10) NULL + ,FOREIGN KEY(parent) REFERENCES Department(shortName) + +); + +CREATE TABLE Employee ( + + ssn CHAR(11) NOT NULL + ,PRIMARY KEY(ssn) + + ,commonName VARCHAR(30) NOT NULL + + ,department CHAR(10) NULL + ,FOREIGN KEY(department) REFERENCES Department(shortName) + +); + +INSERT INTO Department VALUES('fs', 'Financial Services', NULL); +INSERT INTO Department VALUES('cust', 'Customer Relations', 'fs'); +INSERT INTO Department VALUES('support', 'Customer Support', 'cust'); +INSERT INTO Department VALUES('4you', 'Marketing for you', 'fs'); +INSERT INTO Department VALUES('dev', 'Development', NULL); + +INSERT INTO Employee VALUES('987-65-4320', 'Sue Baker', 'dev'); +INSERT INTO Employee VALUES('987-65-4326', 'Jim Smith', 'support'); diff --git a/Klausuren/Sda1/2016Winter/Exam/pom.xml b/Klausuren/Sda1/2016Winter/Exam/pom.xml new file mode 100644 index 000000000..a696ae159 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/pom.xml @@ -0,0 +1,158 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>de.hdm-stuttgart.mi.sda1</groupId> + <artifactId>sda1_2016winter_exam</artifactId> + <version>1.0</version> + <packaging>jar</packaging> + + <name>sda1_2016winter_exam</name> + + <url>http://freedocs.mi.hdm-stuttgart.de</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <repositories> + <repository> + <id>hdm-mi-internal-maven-repo</id> + <url>https://maven.mi.hdm-stuttgart.de/artifacts</url> + </repository> + </repositories> + + <dependencies> + + <dependency> + <groupId>org.opengis.cite.xerces</groupId> + <artifactId>xercesImpl-xsd11</artifactId> + <version>2.12-beta-r1667115</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + <optional>true</optional> + </dependency> + + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>5.1.36</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>2.1</version> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.1</version> + </dependency> + + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom2</artifactId> + <version>2.0.6</version> + </dependency> + + <dependency> + <groupId>jaxen</groupId> + <artifactId>jaxen</artifactId> + <version>1.1.6</version> + </dependency> + + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + <version>5.2.5.Final</version> + </dependency> + + <dependency> + <groupId>de.hdm_stuttgart.mi.exam</groupId> + <artifactId>unitmarking</artifactId> + <version>0.9</version> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.5.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <compilerArgument>-proc:none</compilerArgument> + </configuration> + </plugin> + + <plugin> + <groupId>org.bsc.maven</groupId> + <artifactId>maven-processor-plugin</artifactId> + <version>3.2.0</version> + + <executions> + <execution> + <id>process</id> + <goals> + <goal>process</goal> + </goals> + <phase>generate-sources</phase> + <configuration> + <outputDirectory>${project.build.directory}/metamodel</outputDirectory> + <processors> + <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> + </processors> + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-jpamodelgen</artifactId> + <version>5.2.5.Final</version> + </dependency> + </dependencies> + </plugin> + + <!-- Build helper plugin to add generated sources to classpath --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.12</version> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.build.directory}/metamodel</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.10.1</version> + <configuration /> + </plugin> + </plugins> + </build> +</project> diff --git a/Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Department.java b/Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Department.java new file mode 100644 index 000000000..e29b269e6 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Department.java @@ -0,0 +1,68 @@ +package de.hdm_stuttgart.mi.sda1.exam.dataexport.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; + +/** + * Representing a company's employees. + */ +@Entity +public class Department { + + @Id + @Column(nullable=false) + String shortname;// Cannot be "short" for obvious reasons. + + + /** + * @return A Department's abbreviated name e.g. "fs" representing + * "Financial Services". + */ + public String getShort() { + return shortname; + } + /** + * @param shortname See {@link #getShort()} + */ + public void setShort(String shortname) { + this.shortname = shortname; + } + + + @Column(nullable=false) + String name; + /** + * @return A Department's full name e.g. "Financial Services" + */ + public String getName() { + return name; + } + /** + * @param name See {@link #getName()} + */ + public void setName(String name) { + this.name = name; + } + + + @ManyToOne() + @JoinColumn(name="parent") // Prevent JPA from choosing "parent_short" + Department parent; + /** + * @return A parent department if existing, null otherwise + */ + public Department getParent() { + return parent; + } + + /** + * @param parent See {@link #getParent()} + */ + public void setParent(Department parent) { + this.parent = parent; + } +} \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/jdbcexport/EmployeeInfo.java b/Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/jdbcexport/EmployeeInfo.java new file mode 100644 index 000000000..26fc78692 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/jdbcexport/EmployeeInfo.java @@ -0,0 +1,33 @@ +package de.hdm_stuttgart.mi.sda1.exam.jdbcexport; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + + +/** + * Exporting company data. Execution requires importing corresponding + * schema and optionally sample data from Sql/sample.sql + */ +public class EmployeeInfo { + + /** + * @param args Unused + * @throws SQLException Diagnosing database problems. + */ + public static void main( String[] args ) throws SQLException { + + try (final Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/hdm", "hdmuser", "XYZ")) { + + final Statement queryDepartments = conn.createStatement(); + + final ResultSet departments = queryDepartments.executeQuery("SELECT * FROM Department"); + + while (departments.next()) { + System.out.println(departments.getString("name")); + } + } + } +} \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/jpaexport/EmployeeInfo.java b/Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/jpaexport/EmployeeInfo.java new file mode 100644 index 000000000..1778f3ce7 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/src/main/java/de/hdm_stuttgart/mi/sda1/exam/jpaexport/EmployeeInfo.java @@ -0,0 +1,49 @@ +package de.hdm_stuttgart.mi.sda1.exam.jpaexport; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; + +import de.hdm_stuttgart.mi.sda1.exam.dataexport.model.Department; + +/** + * Exporting company data. Execution requires importing corresponding + * schema and optionally sample data from Sql/sample.sql + */ +public class EmployeeInfo { + + /** + * This refers to a corresponding element {@code <persistence-unit name = "strategy_none" >} + * in META-INF/persistence.xml leaving the Database "as is". + */ + static public final String PERSISTENCE_UNIT_NONE = "strategy_none"; + /** + * @param args Unused + */ + public static void main( String[] args ) { + + final EntityManagerFactory factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NONE); + final EntityManager em = factory.createEntityManager(); + + // TODO: You may change the following code to search for employees first. + + // Selecting all departments + final CriteriaBuilder cb = em.getCriteriaBuilder(); + final CriteriaQuery<Department> cq = cb.createQuery(Department.class); + cq.from(Department.class); // Set query root, don't forget me! + + em.getTransaction().begin(); + + for (final Department d: em.createQuery(cq).getResultList()) { + System.out.println(d.getName()); + } + + + em.getTransaction().commit(); + + em.close(); + factory.close(); + } +} diff --git a/Klausuren/Sda1/2016Winter/Exam/src/main/resources/META-INF/persistence.xml b/Klausuren/Sda1/2016Winter/Exam/src/main/resources/META-INF/persistence.xml new file mode 100644 index 000000000..8ea82e751 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,96 @@ +<persistence + version="2.1" + xmlns="http://xmlns.jcp.org/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence + http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> + + <!-- + The <code>persistence.xml</code> file configures at least one persistence unit; + each unit must have a unique name. + --> + <persistence-unit name = "strategy_drop-and-create"> + + <!-- + Hibernate will scan your classpath for mapped classes and add them automatically + to your persistence unit. + --> + <exclude-unlisted-classes>false</exclude-unlisted-classes> + + <!-- + setting the previous option "exclude-unlisted-classes" to 'true' requires entity classes to + be listed explicitely. You may want to uncomment the following definition and add more classes. + + <class>jpaintro.university.Airline</class> + --> + + <!-- + Standard or vendor-specific options can be set as properties on a persistence unit. + Any standard properties have the <code>javax.persistence</code> name prefix, Hibernate's + settings use <code>hibernate</code> + --> + <properties> + <!-- + JDBC database connection parameter + --> + <property name = "javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> + <property name = "javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hdm?useSSL=false"/> + <property name = "javax.persistence.jdbc.user" value="hdmuser"/> + <property name = "javax.persistence.jdbc.password" value="XYZ"/> + + <!-- + The JPA engine should drop and re-create the SQL schema in the database + automatically when it boots. This is ideal for automated testing, when + you want to work with a clean database for every test run. + --> + <property + name = "javax.persistence.schema-generation.database.action" + value="drop-and-create"/> + + <!-- + When printing SQL in logs, let Hibernate format the SQL nicely and generate + comments into the SQL string so we know why Hibernate executed the SQL statement. + --> + <property name = "hibernate.show_sql" value = "true" /> + <property name = "hibernate.format_sql" value="true"/> + <property name = "hibernate.use_sql_comments" value="true"/> + + <!-- Choose Mysql's innodb backend --> + <property name = "hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> + + <!-- Enable Hibernate scanning for entity classes and adding them automatically + but not for hbm.xml files. --> + <property name = "hibernate.archive.autodetection" value="class"/> + + </properties> + </persistence-unit> + + <!-- The subsequent persistence unit won't modify the database's schema + javax.persistence.schema-generation.database.action=none + --> + <persistence-unit name = "strategy_none"> + + <exclude-unlisted-classes>false</exclude-unlisted-classes> + + <properties> + <property name = "javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> + <property name = "javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hdm?useSSL=false"/> + <property name = "javax.persistence.jdbc.user" value="hdmuser"/> + <property name = "javax.persistence.jdbc.password" value="XYZ"/> + + <property + name = "javax.persistence.schema-generation.database.action" + value="none"/> + + <property name = "hibernate.show_sql" value = "false" /> + <property name = "hibernate.format_sql" value="true"/> + <property name = "hibernate.use_sql_comments" value="true"/> + + <property name = "hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> + + <property name = "hibernate.archive.autodetection" value="class"/> + + </properties> + </persistence-unit> + +</persistence> diff --git a/Klausuren/Sda1/2016Winter/Exam/src/main/resources/log4j2.xml b/Klausuren/Sda1/2016Winter/Exam/src/main/resources/log4j2.xml new file mode 100644 index 000000000..2b1f17e71 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/src/main/resources/log4j2.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + <Appenders> + <File name="A1" fileName="A1.log" append="false"> + <PatternLayout pattern="%t %-5p %c{2} - %m%n"/> + </File> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/> + </Console> + </Appenders> + <Loggers> + + <Logger name="de.hdm_stuttgart.mi.unitmarking" level="error"> + <AppenderRef ref="A1"/> + </Logger> + + <Root level="error"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Exam/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java b/Klausuren/Sda1/2016Winter/Exam/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java new file mode 100644 index 000000000..ee69648c1 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Exam/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java @@ -0,0 +1,26 @@ +package de.hdm_stuttgart.mi.sda1.exam.xsd.test; + +import org.junit.Assert; +import org.junit.Test; + +import de.hdm_stuttgart.mi.unitmarking.xsd.InstanceSetEvaluation; + +/** + * Unit test for an XML instance set. + */ +@SuppressWarnings("static-method") +public class SchemaTest { + /** + * Testing a suite of XML instances. + */ + @Test + public void testXmlInstanceSet() { + + final InstanceSetEvaluation ise = + new InstanceSetEvaluation("SchemaTest", "Schema/company.xsd"); + + System.out.println(ise.getMessages()); + + Assert.assertTrue(ise.getErrorMessages(), ise.allTestsSucceeded); + } +} diff --git a/Klausuren/Sda1/2016Winter/Solution/.gitignore b/Klausuren/Sda1/2016Winter/Solution/.gitignore new file mode 100644 index 000000000..3498d4a33 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/.gitignore @@ -0,0 +1,4 @@ +/.classpath +/.project +A1.log + diff --git a/Klausuren/Sda1/2016Winter/Solution/Doc/ex1.xhtml b/Klausuren/Sda1/2016Winter/Solution/Doc/ex1.xhtml new file mode 100644 index 000000000..3942ec80f --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/Doc/ex1.xhtml @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE body> +<body xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><h1 +id="preparations">Preparations</h1><p>If not yet present from another exercise +download and unzip the above file <code>exam.zip</code> and import the +resulting »<code>Exam«</code> Maven project directory into your workspace +using »File« ➛ »Import« ➛ »Existing Maven Projects«. Error messages related to +the »SchemaTest« sub directory defining automated schema tests can be safely +ignored and may be manually deleted.</p><p>Subsequently mentioned relative +file and directory path names refer to your project root.</p><h1 +id="description">Description</h1><p>We consider +<code>Schema/sampledata.xml</code> illustrating a data store containing a +company's department and employee information:</p><pre><company xsi:noNamespaceSchemaLocation="company.xsd" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + + <departments> + <department short="fs"> + <name>Financial Services</name> + + <department short="cust"> + <name>Customer Relations</name> + + <department short="support"> + <name>Customer Support</name> + </department> + </department> + + <department short="4you"> + <name>Marketing for you</name> + </department> + + </department> + + <department short="dev"> + <name>Development</name> + </department> + + </departments> + + <employees> + <employee ssn="987-65-4320" department="dev"> + <commonName>Sue Baker</commonName> + </employee> + <employee ssn="987-65-4326" department="support"> + <commonName>Jim Smith</commonName> + </employee> + </employees> + +</company></pre><h2 id="integrityConstraints">Integrity +constraints</h2><ol> + <li><p>A company must have at least one + <code><department></code>.</p></li> + + <li><p><code><department></code> elements may be nested reflecting a + company's hierarchical structure.</p></li> + + <li><p>Each <code><department></code> must have a + »<code>short</code>« attribute value of non-zero length not containing + spaces.</p><p><span style="color:green;font-weight: bold;">Hint:</span> + Find an appropriate data type in <a + href="http://www.w3schools.com/xml/schema_dtypes_string.asp" + target="_blank">http://www.w3schools.com/xml/schema_dtypes_string.asp</a>.</p></li> + + <li><p>Each <code><department></code>'s <code>short</code> attribute + value must be unique among all <code><department></code> + elements.</p><p><span style="color:green;font-weight: bold;">Hint:</span> + Defining a corresponding <code><xs:key></code> requires an XPath + searching for <code><department></code> elements of arbitrary + nesting depth. Choose »<code>.//department</code>« being allowed by XSD's + supported XPath subset. The dot ».« at the beginning matters!</p></li> + + <li><p>A company may have an <strong>arbitrary</strong> number of + <code><employee></code>'s.</p></li> + + <li><p>Each <code><employee></code> requires to carry a common + name.</p></li> + + <li><p>Each <code><employee></code> requires to have a social + security number (ssn) to be unique among all + <code><employee></code>'s.</p></li> + + <li><p>Each <code><employee></code> must be assigned to exactly one + department by means of the <code>department</code> attribute.</p></li> + </ol><h1>Tasks</h1><p>Start from <code>Schema/company.xsd</code>. Extend +this file to provide an XML schema grammar implementing the constraints being +described in the above integrity constraints section.</p><h1>Hints</h1><ul> + <li><p>The sample data file <code>Schema/sampledata.xml</code> illustrates + the constraints previously being described in the above integrity + constraints section.</p></li> + + <li><p><code><xs:keyref></code> definitions require matching data + types.</p></li> + + <li><p>The sub directory <code>SchemaTest</code> provides unit tests + checking your schema for correctness. Some files contained within must be + valid and some are intended to be invalid with respect to your + <code>Schema/company.xsd</code>.</p><p>You should execute + <code>de.hdm_stuttgart.mi.sda1.exam.xsd.SchemaTest</code> from your + project's <code>src/test/java</code> branch as a Junit test. A correct + schema <code>Schema/company.xsd</code> yields output similar to:</p><pre>++ SchemaTest/0115invalid_shortWithSpace.xml: Gaining 1 point. +... +++ SchemaTest/0410invalid_duplicateSsn.xml: Gaining 1 point. +<strong>14 of 14 points have been reached</strong></pre><p>Error correction + examples:</p><dl> + <dt style="color:red;"><strong>Problem: Invalid dependency + file.</strong></dt> + + <dd style="color:red;"><pre>-- SchemaTest/0410invalid_duplicateSsn.xml: + Precondition file <strong>»SchemaTest/0400valid_multipleEmployee.xml«</strong> is invalid: + cvc-identity-constraint.4.3: Key 'departmentOfEmployee' with value 'x' ... + Missing 1 point.</pre><p>Explanation: Gaining points for + <code>SchemaTest/0410invalid_duplicateSsn.xml</code> requires the + related file + <strong>»SchemaTest/0400valid_multipleEmployee.xml«</strong> to be + valid with respect to your schema.</p></dd> + + <dt style="color:green;"><strong>Solution:</strong></dt> + + <dd style="color:green;">Correct your <code>Schema/company.xsd</code> + so that <strong>»SchemaTest/0400valid_multipleEmployee.xml«</strong> + becomes valid.</dd> + + <dt style="color:red;"><strong>Problem: File should be valid / + invalid.</strong></dt> + + <dd style="color:red;"><p>You'll find either of:</p><ul> + <li><pre>-- <strong>SchemaTest/0410invalid_duplicateSsn.xml</strong> is expected to be invalid! Missing 1 point.</pre></li> + + <li><pre>-- <strong>SchemaTest/345valid_foo.xml</strong> is expected to be valid! Missing 1 point.</pre></li> + </ul></dd> + + <dt style="color:green;"><strong>Solution:</strong></dt> + + <dd style="color:green;"><p>Correct your + <code>Schema/company.xsd</code> so that the file in question becomes + valid or invalid respectively. The individual unit test files may + contain XML comments describing the expected error.</p></dd> + </dl></li> + </ul><h1 style="color: red;">Uploading, caution!</h1><ul> + <li><p>Upon completion zip up your Maven project directory and use the + upload facility below. Check for completeness!</p></li> + + <li><p>Mind the remaining time! <b style="color:red;">When the examination + terminates no subsequent uploads will be possible!</b></p></li> + + <li><p><b style="color:red;">In case of multiple uploads only your last + uploaded zip archive will become subject to marking.</b></p></li> + </ul></body> diff --git a/Klausuren/Sda1/2016Winter/Solution/Doc/ex2.xml b/Klausuren/Sda1/2016Winter/Solution/Doc/ex2.xml new file mode 100644 index 000000000..ef7fbc613 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/Doc/ex2.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE body> +<body xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><h1 +id="preparations">Preparations</h1><p>Read the description of the first +exercise.</p><h1 id="description">Description</h1><p>We want to model XML +company data from the first exercise populating a relational database. A +corresponding schema implementation <code>Sql/sample.sql</code> in your +project reads:</p><pre>CREATE TABLE Department( + shortName CHAR(10) NOT NULL + ,PRIMARY KEY(shortName) + + ,name VARCHAR(30) NOT NULL + ,parent CHAR(10) NULL + ,FOREIGN KEY(parent) REFERENCES Department(shortName) +); + +CREATE TABLE Employee ( + ssn CHAR(11) NOT NULL + ,PRIMARY KEY(ssn) + + ,commonName VARCHAR(30) NOT NULL + + ,department CHAR(10) NULL + ,FOREIGN KEY(department) REFERENCES Department(shortName) +);</pre><p>Suitable test data reflecting <code>Schema/sampledata.xml</code> +may be inserted:</p><pre>INSERT INTO Department VALUES('fs', 'Financial Services', NULL); +INSERT INTO Department VALUES('cust', 'Customer Relations', 'fs'); +INSERT INTO Department VALUES('support', 'Customer Support', 'cust'); +INSERT INTO Department VALUES('4you', 'Marketing for you', 'fs'); +INSERT INTO Department VALUES('dev', 'Development', NULL); + +INSERT INTO Employee VALUES('987-65-4320', 'Sue Baker', 'dev'); +INSERT INTO Employee VALUES('987-65-4326', 'Jim Smith', 'support');</pre><h1>Tasks</h1><p>Answer +the following two questions:</p><ol> + <li><p>Why do we need a foreign key <code>parent</code> being defined in + <code><code>Department</code></code> although there is no corresponding + <code><xs:keyref></code> being required in + <code>Schema/company.xsd</code>?</p></li> + + <li>Why does the foreign key <code>parent</code> being defined in + <code><code>Department</code></code> allows for <code>NULL</code> + values?</li> + </ol></body> diff --git a/Klausuren/Sda1/2016Winter/Solution/Doc/ex3.xml b/Klausuren/Sda1/2016Winter/Solution/Doc/ex3.xml new file mode 100644 index 000000000..bac989d01 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/Doc/ex3.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE body> +<body xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><h1 +id="preparations">Preparations</h1><p>If not yet present from another exercise +download <a href="/files/goik/Sda1/hzUUgR4399ghFFHGfbft/exam.zip" +target="_blank">exam.zip</a>, unzip it and import the resulting +<code>Exam</code> directory as a <b>Maven Eclipse</b> project into your +workspace.</p><p>Read the first exercises (»XML company database«) +description. Connect the Eclipse database tools to the local Mysql server and +execute <code>Sql/sample.sql</code> thereby creating a schema and importing +sample data resembling both XML schema and data from the first +exercise.</p><p>Subsequently mentioned relative file and directory path names +refer to your project root.</p><h1>Description</h1><p>As being mentioned in +the second exercise <code>Sql/sample.sql</code> resembles both schema and +example data from your first exercise. We want to export portions of this data +in text form.</p><h1>Tasks</h1><p>Follow the subsequent steps each awarding +points:</p><ol> + <li><p>Write a Java application exporting a numbered list of company + members in no particular order. The textual output shall read:</p><pre>1: Sue Baker +2: Jim Smith</pre></li> + + <li><p>Enhance the previous solution by adding each employees (immediate) + department:</p><pre>1: Sue Baker, department Development +2: Jim Smith, department Customer Support</pre></li> + + <li><p>Further enhance the previous solution by adding each employees top + level department if it differs from his or hers immediate + department:</p><pre>1: Sue Baker, department Development +2: Jim Smith, department Customer Support, Top level department Financial Services</pre><p>In + the given example »Development« already is a top level department. On + contrary the »Customer Support« department is part of »Customer Relations« + which in turn is part of the top level »Financial Services« + department.</p><p><span + style="color:green;font-weight: bold;">Hint:</span> Defining a recursive + method ascending the department hierarchy is your friend. Your solution is + expected to work for an arbitrary nesting depth of departments.</p></li> + </ol><h1>Hints</h1><p>See <a href="#preparations">Preparations</a> for prior +database import. You may use either JPA or plain old JDBC to access your +database following either of:</p><dl> + <dt>JPA</dt> + + <dd><p>An entity + <code>de.hdm_stuttgart.mi.sda1.exam.dataexport.model.Department</code> has + already been defined for your convenience. The + <code>de.hdm_stuttgart.mi.sda1.exam.jpaexport.EmployeeInfo.main(...)</code> + method is ready to run. It retrieves department information from your + database server. You'll have to:</p><ol> + <li>Provide a (very similar) second entity definition + <code>de.hdm_stuttgart.mi.sda1.exam.dataexport.model.Employee</code>. + You need to define a @ManyToOne property linking employees and + departments similar to + <code>de.hdm_stuttgart.mi.sda1.exam.dataexport.model.Department.parent</code>.</li> + + <li>Modify + <code>de.hdm_stuttgart.mi.sda1.exam.dataexport.EmployeeInfo</code> to + read employees rather than departments. </li> + </ol></dd> + + <dt>JDBC</dt> + + <dd><p>The + <code>de.hdm_stuttgart.mi.sda1.exam.jdbcexport.EmployeeInfo.main(...)</code> + method retrieves all departments. You'll have to:</p><ol> + <li>Search for employees in the first place.</li> + + <li>Either code a second query for departments or define an SQL join + linking employees to departments in a suitable way.</li> + </ol></dd> + </dl><h1 style="color: red;">Uploading, caution!</h1><ul> + <li><p>Upon completion zip up your Maven project directory and use the + upload facility of the first »XML company database« exercise. Fill in the + text field below to indicate whether or not you worked on the current + exercise by entering either of:</p><ul> + <li>I did work on the current exercise</li> + + <li>I did not work on the current exercise</li> + </ul></li> + + <li><p>Mind the remaining time! <b style="color:red;">When the examination + terminates no subsequent uploads will be possible!</b></p></li> + + <li><p><b style="color:red;">In case of multiple uploads only your last + uploaded zip archive will become subject to marking.</b></p></li> + </ul></body> diff --git a/Klausuren/Sda1/2016Winter/Solution/Doc/movie2html.xhtml b/Klausuren/Sda1/2016Winter/Solution/Doc/movie2html.xhtml new file mode 100644 index 000000000..4b01c9f41 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/Doc/movie2html.xhtml @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE body> +<body xml:lang="en" +xmlns="http://www.w3.org/1999/xhtml"><h1>Description</h1><p>Transform movie +meta data to Xhtml using Jdom.</p><h1 id="preparations">Preparations</h1><p>If +not yet present from another exercise download <a +href="/files/goik/Sda1/hzUUgR4399ghFFHGfbft/exam.zip" +target="_blank">exam.zip</a>, unzip it and import the resulting +<code>Exam</code> directory as a <b>Maven Eclipse</b> project into your +workspace.</p><p>Subsequently mentioned relative file and directory path names +refer to your project root.</p><h1>Tasks</h1><p>Start from +<code>Schema/testdata.xml</code>. The +<code>de.hdm_stuttgart.mi.sda1.exam.movie_by_actor.Moviedb2MovieByActor</code> +class contains a <code>Document process(Document input)</code> method which +allows for transforming Jdom input to a different Jdom output.</p><p>You are +expected to transform Xml input data like in <code>Schema/testdata.xml</code> +into a list of actors among with all movies they participated in.</p><pre><html> + <body> + <h1>List of actors among with their corresponding films</h1> + <dl> + <dt>Andie MacDowell</dt> + <dd> + <p>Short Cuts</p> + </dd> + <dt>Matthew Modine</dt> + <dd> + <p>Full Metal Jacket</p> + <p>Short Cuts</p> + </dd> + <dt>R. Lee Ermey</dt> + <dd> + <p>Full Metal Jacket</p> + </dd> + </dl> + </body> +</html></pre><p>We are only interested in actors who participated in at +least one film. Technically this means that there must be at least one +<code><actor ref="xyz"/></code> reference for an actor to show up. The +<person> <b>Robert Altman</b> for example does not show up in the above +Xhtml output: Robert Altman appears as a director in +<code>Schema/testdata.xml</code> but not as an actor and is thus being +excluded. On contrary Matthew Modine shows up together with two films he did +participate in as an actor.</p><p>Your application is expected to work for +input data being different from the <code>Schema/testdata.xml</code> sample +data accordingly.</p><h1>Hints</h1><ol type="a"> + <li><p>Your downloaded project does contain helpful boilerplate code. + Executing + <code>de.hdm_stuttgart.mi.sda1.exam.movie_by_actor.TestMoviesByActor</code> + already yields both a Xhtml skeleton:</p><pre><html> + <body> + <h1>List of actors among with their corresponding films</h1> + <dl> + <b><!--To be implemented by you in class + de.hdm_stuttgart.mi.sda1.exam.movie_by_actor.Moviedb2MovieByActor--></b> + </dl> + </body> +</html></pre></li> + + <li><p>The above mentioned Junit tests also examine your generated Xhtml + output by Xpath expressions e.g. checking for the number of expected + <code><dt></code> elements appearing on output below + <code><dl></code>. Test execution yields a regular Junit test + result.</p></li> + + <li><p>Running + <code>de.hdm_stuttgart.mi.sda1.exam.movie_by_actor.ShowReachedPoints</code> + from your project's Junit test branch as a Java application (not as a + Junit test) executes all tests and shows your current achievement with + respect to marking:</p><pre>TestMoviesByActor: 12/12 +Sum (12/12)</pre></li> + </ol><p>You may follow the subsequent implementation sketch:</p><ol> + <li><p>Traverse the <code>movieDb/person</code> hierarchy. This allows for + creating the desired <code><dt></code> entries.</p></li> + + <li><p>For each <person id='xyz' ..> use a suitable Xpath expression + to retrieve a <code>java.util.List<Element></code> instance of + related <code><movie></code> elements by using the actor's + <code>@id</code> value. The following Jdom snippet may be + helpful:</p><pre>final XPathExpression<Element> xpath = XPathFactory.instance().compile("my/x/path", Filters.element()); + +final List<Element> result = xpath.evaluate(contextNode);</pre><p>In + case you are not familiar with Xpath you may descend the input tree by + repeatedly calling getChildren() to find matching + <code><movie></code> entries.</p></li> + + <li><p>Include only those <code><person></code> entries having at + least one matching <code><movie></code> record.</p></li> + </ol><h1 style="color: red;">Uploading, caution!</h1><ul> + <li><p>Upon completion zip up your Maven project directory use the upload + facility of the first “XML movie database†schema exercise. Use the text + field below to indicate whether or not you worked on the current exercise + by entering either of:</p><ul> + <li>I did work on the current exercise</li> + + <li>I did not work on the current exercise</li> + </ul></li> + + <li><p>Mind the remaining time! <b style="color:red;">When the examination + terminates no subsequent uploads will be possible!</b></p></li> + + <li><p><b style="color:red;">In case of multiple uploads only your last + uploaded zip archive will become subject to marking.</b></p></li> + </ul></body> diff --git a/Klausuren/Sda1/2016Winter/Solution/Doc/movieSql.xhtml b/Klausuren/Sda1/2016Winter/Solution/Doc/movieSql.xhtml new file mode 100644 index 000000000..91976c31d --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/Doc/movieSql.xhtml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE body> +<body xml:lang="en" +xmlns="http://www.w3.org/1999/xhtml"><h1>Description</h1><p>Creation of an SQL +schema modeling a relational movie database.</p><h1 +id="preparations">Preparations</h1><p>If not yet present from another exercise +download <a href="/files/goik/Sda1/hzUUgR4399ghFFHGfbft/exam.zip" +target="_blank">exam.zip</a>, unzip it and import the resulting +<code>Exam</code> directory as a <b>Maven Eclipse</b> project into your +workspace. Subsequently mentioned relative file and directory path names refer +to your project root.</p><h1>Tasks</h1><ol> + <li><p>Start from <code>Schema/movie.sql</code>. Extend this schema to + resemble the constraints being described in the previous XSD schema + exercise Data model description as closely as possible.</p></li> + + <li><p>Manually create appropriate SQL <code>INSERT</code> statements to + insert <b>all</b> data being present in <code>Schema/sampledata.xml</code> + into your database. This is a proof of concept step.</p></li> + </ol><h1>Hints</h1><ul> + <li>Which entities do exist and how are they related (cardinalities!) + ?</li> + + <li>The Mysql data type TEXT allows for strings exceeding 255 + characters.</li> + + <li>Mysql supports the <code>BOOLEAN</code> data type.</li> + + <li>Even without completing the XSD exercise you may model this SQL + schema.</li> + </ul><h1 style="color: red;">Uploading, caution!</h1><ul> + <li><p>Upon completion zip up your Maven project directory use the upload + facility of the first “XML movie database†schema exercise. Use the text + field below to indicate whether or not you worked on the current exercise + by entering either of:</p><ul> + <li>I did work on the current exercise</li> + + <li>I did not work on the current exercise</li> + </ul></li> + + <li><p>Mind the remaining time! <b style="color:red;">When the examination + terminates no subsequent uploads will be possible!</b></p></li> + + <li><p><b style="color:red;">In case of multiple uploads only your last + uploaded zip archive will become subject to marking.</b></p></li> + </ul></body> diff --git a/Klausuren/Sda1/2016Winter/Solution/Schema/company.xsd b/Klausuren/Sda1/2016Winter/Solution/Schema/company.xsd new file mode 100644 index 000000000..c420c4511 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/Schema/company.xsd @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > + + <xs:element name="company"> + <xs:complexType> + <xs:sequence> + <xs:element name="departments"> + <xs:complexType> + <xs:sequence> + <xs:element ref="department" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="employees"> + <xs:complexType> + <xs:sequence> + <xs:element ref="employee" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + <xs:key name="uniqueSsn"> + <xs:selector xpath="employee"/> + <xs:field xpath="@ssn"/> + </xs:key> + </xs:element> + </xs:sequence> + </xs:complexType> + + <xs:key name="uniqueDepartmentShortName"> + <xs:selector xpath=".//department"/> + <xs:field xpath="@short"/> + </xs:key> + + <xs:keyref refer="uniqueDepartmentShortName" name="departmentOfEmployee"> + <xs:selector xpath="employees/employee"/> + <xs:field xpath="@department"/> + </xs:keyref> + </xs:element> + + <xs:element name="department"> + <xs:complexType> + <xs:sequence> + <xs:element name="name" type="xs:string"/> + <xs:element ref="department" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="short" type="xs:NMTOKEN" use="required"/> + </xs:complexType> + + </xs:element> + + <xs:element name="employee"> + <xs:complexType> + <xs:sequence> + <xs:element name="commonName"/> + </xs:sequence> + <xs:attribute name="ssn" use="required"/> + <xs:attribute name="department" type="xs:NMTOKEN" use="required"/> + </xs:complexType> + </xs:element> + +</xs:schema> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/Schema/sampledata.xml b/Klausuren/Sda1/2016Winter/Solution/Schema/sampledata.xml new file mode 100644 index 000000000..fae13b2a3 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/Schema/sampledata.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company xsi:noNamespaceSchemaLocation="company.xsd" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + + <departments> + <department short="fs"> + <name>Financial Services</name> + + <department short="cust"> + <name>Customer Relations</name> + + <department short="support"> + <name>Customer Support</name> + </department> + </department> + + <department short="4you"> + <name>Marketing for you</name> + </department> + + </department> + + <department short="dev"> + <name>Development</name> + </department> + + </departments> + + <employees> + <employee ssn="987-65-4320" department="dev"> + <commonName>Sue Baker</commonName> + </employee> + <employee ssn="987-65-4326" department="support"> + <commonName>Jim Smith</commonName> + </employee> + </employees> + +</company> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0100valid_minimum.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0100valid_minimum.xml new file mode 100644 index 000000000..ce221a1c7 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0100valid_minimum.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees/> + +</company> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0115invalid_shortWithSpace.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0115invalid_shortWithSpace.xml new file mode 100644 index 000000000..81e3a6b08 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0115invalid_shortWithSpace.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a b"> <!-- Error: @short must not contain spaces --> + <name>A</name> + </department> + </departments> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0120invalid_duplicateShort.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0120invalid_duplicateShort.xml new file mode 100644 index 000000000..6444aa5bd --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0120invalid_duplicateShort.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="abc"> + <name>A</name> + </department> + + <department short="abc"> <!-- Error: Duplicate @short value "abc" --> + <name>A</name> + </department> + </departments> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0125invalid_noShort.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0125invalid_noShort.xml new file mode 100644 index 000000000..e5b79eb8d --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0125invalid_noShort.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department > <!-- Error: @short attribute undefined --> + <name>A</name> + </department> + </departments> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0130invalid_shortZeroLength.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0130invalid_shortZeroLength.xml new file mode 100644 index 000000000..9794632c8 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0130invalid_shortZeroLength.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short=""> <!-- Error: @short has zero length --> + <name>A</name> + </department> + </departments> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0140invalid_noDepartment.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0140invalid_noDepartment.xml new file mode 100644 index 000000000..1f7e8447f --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0140invalid_noDepartment.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments/> <!-- Error: Need at least one <department> --> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0145invalid_noName.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0145invalid_noName.xml new file mode 100644 index 000000000..8456f73c1 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0145invalid_noName.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + <name>B</name> <!-- Error: <name> must appear exactly once --> + </department> + </departments> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0150invalid_duplicateName.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0150invalid_duplicateName.xml new file mode 100644 index 000000000..c3e9279f4 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0150invalid_duplicateName.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments/> <!-- Error: Need at least one department --> + + <employees/> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0200valid_nesting.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0200valid_nesting.xml new file mode 100644 index 000000000..25c5bd7d0 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0200valid_nesting.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + <department short="b"> + <name>B</name> + <department short="c"> + <name>C</name> + <department short="d"> + <name>D</name> + </department> + <department short="e"> + <name>E</name> + </department> + </department> + </department> + </department> + </departments> + + <employees/> + +</company> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0210invalid_nestingDuplicateShort.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0210invalid_nestingDuplicateShort.xml new file mode 100644 index 000000000..01da54ae9 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0210invalid_nestingDuplicateShort.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + <department short="abc"> + <name>B</name> + <department short="abc"> <!-- Error: duplicate @short value "abc" --> + <name>C</name> + <department short="d"> + <name>D</name> + </department> + </department> + </department> + </department> + </departments> + <employees/> +</company> + +<?xmlTest + points = "2" + expectedToBeValid = "false" + preconditionValid = "0200valid_nesting.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0300valid_minEmployee.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0300valid_minEmployee.xml new file mode 100644 index 000000000..ef0e10971 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0300valid_minEmployee.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="123-33-2213" department="a"> + <commonName>Pam Baker</commonName> + </employee> + </employees> + +</company> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0305invalid_NoDepartment.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0305invalid_NoDepartment.xml new file mode 100644 index 000000000..92f46bcb2 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0305invalid_NoDepartment.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="123-33-2213"> <!--Error: missing department attribute --> + <commonName>Pam Baker</commonName> + </employee> + </employees> + +</company> + +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0300valid_minEmployee.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0310invalid_NoSsn.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0310invalid_NoSsn.xml new file mode 100644 index 000000000..99f9ba3e5 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0310invalid_NoSsn.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee department="a"> <!--Error: missing ssn attribute --> + <commonName>Pam Baker</commonName> + </employee> + </employees> + +</company> + +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0300valid_minEmployee.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0315invalid_NoCommonName.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0315invalid_NoCommonName.xml new file mode 100644 index 000000000..16bc7f587 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0315invalid_NoCommonName.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="213-55-3213" department="a"/> <!--Error: missing <commonName> --> + </employees> + +</company> + +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0300valid_minEmployee.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0325invalid_duplicateCommonName.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0325invalid_duplicateCommonName.xml new file mode 100644 index 000000000..a34c36329 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0325invalid_duplicateCommonName.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="123-33-2213" department="a"> + <commonName>Pam Baker</commonName> + <commonName>Tim Berners Lee</commonName> + </employee> + </employees> + +</company> +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0300valid_minEmployee.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0400valid_multipleEmployee.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0400valid_multipleEmployee.xml new file mode 100644 index 000000000..d87bf34ce --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0400valid_multipleEmployee.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="123-33-2213" department="a"> + <commonName>Pam Baker</commonName> + </employee> + <employee ssn="123-33-2215" department="a"> + <commonName>Pam Baker</commonName> + </employee> + </employees> + +</company> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0410invalid_duplicateSsn.xml b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0410invalid_duplicateSsn.xml new file mode 100644 index 000000000..c7e4a115b --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/SchemaTest/0410invalid_duplicateSsn.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<company + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/company.xsd"> + + <departments> + <department short="a"> + <name>A</name> + </department> + </departments> + + <employees> + <employee ssn="123-33-2213" department="a"> + <commonName>Pam Baker</commonName> + </employee> + <employee ssn="123-33-2213" department="a"> <!--Error: Duplicate ssn --> + <commonName>Pam Baker</commonName> + </employee> + </employees> + +</company> + +<?xmlTest + points = "1" + expectedToBeValid = "false" + preconditionValid = "0400valid_multipleEmployee.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/Sql/sample.sql b/Klausuren/Sda1/2016Winter/Solution/Sql/sample.sql new file mode 100644 index 000000000..4cb56af4b --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/Sql/sample.sql @@ -0,0 +1,34 @@ +DROP TABLE IF EXISTS Employee; +DROP TABLE IF EXISTS Department; + +CREATE TABLE Department( + + shortName CHAR(10) NOT NULL + ,PRIMARY KEY(shortName) + + ,name VARCHAR(30) NOT NULL + ,parent CHAR(10) NULL + ,FOREIGN KEY(parent) REFERENCES Department(shortName) + +); + +CREATE TABLE Employee ( + + ssn CHAR(11) NOT NULL + ,PRIMARY KEY(ssn) + + ,commonName VARCHAR(30) NOT NULL + + ,department CHAR(10) NULL + ,FOREIGN KEY(department) REFERENCES Department(shortName) + +); + +INSERT INTO Department VALUES('fs', 'Financial Services', NULL); +INSERT INTO Department VALUES('cust', 'Customer Relations', 'fs'); +INSERT INTO Department VALUES('support', 'Customer Support', 'cust'); +INSERT INTO Department VALUES('4you', 'Marketing for you', 'fs'); +INSERT INTO Department VALUES('dev', 'Development', NULL); + +INSERT INTO Employee VALUES('987-65-4320', 'Sue Baker', 'dev'); +INSERT INTO Employee VALUES('987-65-4326', 'Jim Smith', 'support'); diff --git a/Klausuren/Sda1/2016Winter/Solution/pom.xml b/Klausuren/Sda1/2016Winter/Solution/pom.xml new file mode 100644 index 000000000..92a0fcd48 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/pom.xml @@ -0,0 +1,158 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>de.hdm-stuttgart.mi.sda1</groupId> + <artifactId>sda1_2016winter_solve</artifactId> + <version>1.0</version> + <packaging>jar</packaging> + + <name>sda1_2016winter_solve</name> + + <url>http://freedocs.mi.hdm-stuttgart.de</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <repositories> + <repository> + <id>hdm-mi-internal-maven-repo</id> + <url>https://maven.mi.hdm-stuttgart.de/artifacts</url> + </repository> + </repositories> + + <dependencies> + + <dependency> + <groupId>org.opengis.cite.xerces</groupId> + <artifactId>xercesImpl-xsd11</artifactId> + <version>2.12-beta-r1667115</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + <optional>true</optional> + </dependency> + + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>5.1.36</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>2.1</version> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.1</version> + </dependency> + + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom2</artifactId> + <version>2.0.6</version> + </dependency> + + <dependency> + <groupId>jaxen</groupId> + <artifactId>jaxen</artifactId> + <version>1.1.6</version> + </dependency> + + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + <version>5.2.5.Final</version> + </dependency> + + <dependency> + <groupId>de.hdm_stuttgart.mi.exam</groupId> + <artifactId>unitmarking</artifactId> + <version>0.9</version> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.5.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <compilerArgument>-proc:none</compilerArgument> + </configuration> + </plugin> + + <plugin> + <groupId>org.bsc.maven</groupId> + <artifactId>maven-processor-plugin</artifactId> + <version>3.2.0</version> + + <executions> + <execution> + <id>process</id> + <goals> + <goal>process</goal> + </goals> + <phase>generate-sources</phase> + <configuration> + <outputDirectory>${project.build.directory}/metamodel</outputDirectory> + <processors> + <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> + </processors> + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-jpamodelgen</artifactId> + <version>5.2.5.Final</version> + </dependency> + </dependencies> + </plugin> + + <!-- Build helper plugin to add generated sources to classpath --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.12</version> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.build.directory}/metamodel</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.10.1</version> + <configuration /> + </plugin> + </plugins> + </build> +</project> diff --git a/Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/EmployeeInfo.java b/Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/EmployeeInfo.java new file mode 100644 index 000000000..75d77adee --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/EmployeeInfo.java @@ -0,0 +1,65 @@ +package de.hdm_stuttgart.mi.sda1.exam.dataexport; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; + +import de.hdm_stuttgart.mi.sda1.exam.dataexport.model.Department; +import de.hdm_stuttgart.mi.sda1.exam.dataexport.model.Employee; + +/** + * Exporting company data. Execution requires importing corresponding + * schema and optionally sample data from Sql/sample.sql + */ +public class EmployeeInfo { + + /** + * This refers to a corresponding element {@code <persistence-unit name = "strategy_none" >} + * in META-INF/persistence.xml leaving the Database "as is". + */ + static public final String PERSISTENCE_UNIT_NONE = "strategy_none"; + /** + * @param args Unused + */ + public static void main( String[] args ) { + + final EntityManagerFactory factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NONE); + final EntityManager em = factory.createEntityManager(); + + // Selecting all employees + final CriteriaBuilder cb = em.getCriteriaBuilder(); + final CriteriaQuery<Employee> cq = cb.createQuery(Employee.class); + cq.from(Employee.class); // Set query root, don't forget me! + + em.getTransaction().begin(); + + int index = 1; + for (final Employee e: em.createQuery(cq).getResultList()) { + System.out.println(index++ + ": " + getInfo(e)); + } + + em.getTransaction().commit(); + + em.close(); + factory.close(); + } + + static String getInfo(final Employee e) { + final StringBuffer ret = new StringBuffer(e.getCommonName() + ", department " + e.getDepartment().getName()); + + final Department rootDepartment = getRootDepartment(e.getDepartment()); + if (rootDepartment != e.getDepartment()) { + ret.append(", Top level department " + rootDepartment.getName()); + } + return ret.toString(); + } + + static Department getRootDepartment(Department d) { + while (null != d.getParent()) { + d = d.getParent(); + } + return d; + } +} \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Department.java b/Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Department.java new file mode 100644 index 000000000..e29b269e6 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Department.java @@ -0,0 +1,68 @@ +package de.hdm_stuttgart.mi.sda1.exam.dataexport.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; + +/** + * Representing a company's employees. + */ +@Entity +public class Department { + + @Id + @Column(nullable=false) + String shortname;// Cannot be "short" for obvious reasons. + + + /** + * @return A Department's abbreviated name e.g. "fs" representing + * "Financial Services". + */ + public String getShort() { + return shortname; + } + /** + * @param shortname See {@link #getShort()} + */ + public void setShort(String shortname) { + this.shortname = shortname; + } + + + @Column(nullable=false) + String name; + /** + * @return A Department's full name e.g. "Financial Services" + */ + public String getName() { + return name; + } + /** + * @param name See {@link #getName()} + */ + public void setName(String name) { + this.name = name; + } + + + @ManyToOne() + @JoinColumn(name="parent") // Prevent JPA from choosing "parent_short" + Department parent; + /** + * @return A parent department if existing, null otherwise + */ + public Department getParent() { + return parent; + } + + /** + * @param parent See {@link #getParent()} + */ + public void setParent(Department parent) { + this.parent = parent; + } +} \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Employee.java b/Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Employee.java new file mode 100644 index 000000000..76007fe51 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/model/Employee.java @@ -0,0 +1,63 @@ +package de.hdm_stuttgart.mi.sda1.exam.dataexport.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +/** + * Representing a company's employees. + */ +@Entity +public class Employee { + + @Id + @Column(nullable=false) + String ssn; + + /** + * @return A person's social security number. + */ + public String getSsn() { + return ssn; + } + + /** + * @param ssn see {@link #getSsn()}} + */ + public void setSsn(String ssn) { + this.ssn = ssn; + } + + @Column(nullable=false) + String commonName; + /** + * @return A person's common name e.g. Jane Smith. + */ + public String getCommonName() { + return commonName; + } + /** + * @param commonName see {@link #getCommonName()} + */ + public void setCommonName(String commonName) { + this.commonName = commonName; + } + @ManyToOne + @JoinColumn(name="department") // Prevent JPA from choosing "department_short" + Department department; + /** + * @return An Employee's department. + */ + public Department getDepartment() { + return department; + } + + /** + * @param department see {@link #getDepartment()} + */ + public void setDepartment(Department department) { + this.department = department; + } +} \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/src/main/resources/META-INF/persistence.xml b/Klausuren/Sda1/2016Winter/Solution/src/main/resources/META-INF/persistence.xml new file mode 100644 index 000000000..8ea82e751 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,96 @@ +<persistence + version="2.1" + xmlns="http://xmlns.jcp.org/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence + http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> + + <!-- + The <code>persistence.xml</code> file configures at least one persistence unit; + each unit must have a unique name. + --> + <persistence-unit name = "strategy_drop-and-create"> + + <!-- + Hibernate will scan your classpath for mapped classes and add them automatically + to your persistence unit. + --> + <exclude-unlisted-classes>false</exclude-unlisted-classes> + + <!-- + setting the previous option "exclude-unlisted-classes" to 'true' requires entity classes to + be listed explicitely. You may want to uncomment the following definition and add more classes. + + <class>jpaintro.university.Airline</class> + --> + + <!-- + Standard or vendor-specific options can be set as properties on a persistence unit. + Any standard properties have the <code>javax.persistence</code> name prefix, Hibernate's + settings use <code>hibernate</code> + --> + <properties> + <!-- + JDBC database connection parameter + --> + <property name = "javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> + <property name = "javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hdm?useSSL=false"/> + <property name = "javax.persistence.jdbc.user" value="hdmuser"/> + <property name = "javax.persistence.jdbc.password" value="XYZ"/> + + <!-- + The JPA engine should drop and re-create the SQL schema in the database + automatically when it boots. This is ideal for automated testing, when + you want to work with a clean database for every test run. + --> + <property + name = "javax.persistence.schema-generation.database.action" + value="drop-and-create"/> + + <!-- + When printing SQL in logs, let Hibernate format the SQL nicely and generate + comments into the SQL string so we know why Hibernate executed the SQL statement. + --> + <property name = "hibernate.show_sql" value = "true" /> + <property name = "hibernate.format_sql" value="true"/> + <property name = "hibernate.use_sql_comments" value="true"/> + + <!-- Choose Mysql's innodb backend --> + <property name = "hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> + + <!-- Enable Hibernate scanning for entity classes and adding them automatically + but not for hbm.xml files. --> + <property name = "hibernate.archive.autodetection" value="class"/> + + </properties> + </persistence-unit> + + <!-- The subsequent persistence unit won't modify the database's schema + javax.persistence.schema-generation.database.action=none + --> + <persistence-unit name = "strategy_none"> + + <exclude-unlisted-classes>false</exclude-unlisted-classes> + + <properties> + <property name = "javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> + <property name = "javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hdm?useSSL=false"/> + <property name = "javax.persistence.jdbc.user" value="hdmuser"/> + <property name = "javax.persistence.jdbc.password" value="XYZ"/> + + <property + name = "javax.persistence.schema-generation.database.action" + value="none"/> + + <property name = "hibernate.show_sql" value = "false" /> + <property name = "hibernate.format_sql" value="true"/> + <property name = "hibernate.use_sql_comments" value="true"/> + + <property name = "hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> + + <property name = "hibernate.archive.autodetection" value="class"/> + + </properties> + </persistence-unit> + +</persistence> diff --git a/Klausuren/Sda1/2016Winter/Solution/src/main/resources/log4j2.xml b/Klausuren/Sda1/2016Winter/Solution/src/main/resources/log4j2.xml new file mode 100644 index 000000000..2b1f17e71 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/src/main/resources/log4j2.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + <Appenders> + <File name="A1" fileName="A1.log" append="false"> + <PatternLayout pattern="%t %-5p %c{2} - %m%n"/> + </File> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/> + </Console> + </Appenders> + <Loggers> + + <Logger name="de.hdm_stuttgart.mi.unitmarking" level="error"> + <AppenderRef ref="A1"/> + </Logger> + + <Root level="error"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/Klausuren/Sda1/2016Winter/Solution/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java b/Klausuren/Sda1/2016Winter/Solution/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java new file mode 100644 index 000000000..ee69648c1 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java @@ -0,0 +1,26 @@ +package de.hdm_stuttgart.mi.sda1.exam.xsd.test; + +import org.junit.Assert; +import org.junit.Test; + +import de.hdm_stuttgart.mi.unitmarking.xsd.InstanceSetEvaluation; + +/** + * Unit test for an XML instance set. + */ +@SuppressWarnings("static-method") +public class SchemaTest { + /** + * Testing a suite of XML instances. + */ + @Test + public void testXmlInstanceSet() { + + final InstanceSetEvaluation ise = + new InstanceSetEvaluation("SchemaTest", "Schema/company.xsd"); + + System.out.println(ise.getMessages()); + + Assert.assertTrue(ise.getErrorMessages(), ise.allTestsSucceeded); + } +} diff --git a/Klausuren/Sda1/2016Winter/Solution/todo.txt b/Klausuren/Sda1/2016Winter/Solution/todo.txt new file mode 100644 index 000000000..acfc1cbc5 --- /dev/null +++ b/Klausuren/Sda1/2016Winter/Solution/todo.txt @@ -0,0 +1,6 @@ +Oracle SQL JDeveloper konfigurieren +Mysql connection in eclipse konfigurieren. +Maven dependencies aktualisieren und import testen +http://dev.personabrowser.gpii.eu/en +Notfall Accounts ILIAS aufsetzen +Update Klausur SoSe2016 + Info Sda1 Teilnehmer. diff --git a/Klausuren/Sda1/Papier/113305.tex b/Klausuren/Sda1/Papier/113305.tex new file mode 100644 index 000000000..55903d0aa --- /dev/null +++ b/Klausuren/Sda1/Papier/113305.tex @@ -0,0 +1,47 @@ +\documentclass[11pt]{article} + +\input{commonarticle} +\usepackage{fullpage} +\usepackage{listings} +\input{klausurdef} + +\newcommand{\klausurautor}{Martin Goik} +\newcommand{\vorlesung}{Ws 2016} +\newcommand{\semester}{3. Semester} +\newcommand{\dauer}{120} +\newcommand{\fach}{Structured Data and Applications 1} +\newcommand{\plandatum}{10.02.2017, 10:00} +\newcommand{\edvnr}{113305} +\newcommand{\hilfsmittel}{Vom Sekretariat geprüfte Wörterbücher} +\newcommand{\studiengang}{MIB} + + +%\renewcommand{\aufgloes}{loesung} + +\begin{document} + +\headheight30pt +\headsep5mm +\klausurhead + + +\input{xsd} +\input{prepared} +\input{jdom} +\input{jdomerror} +\input{bonus} + +\newpage + + + +%\fremdaufgabe{Darst.}{2} + + +\konzeptseiten{2} + + +\klausurtail + + +\end{document} diff --git a/Klausuren/Sda1/Papier/Code/.gitignore b/Klausuren/Sda1/Papier/Code/.gitignore new file mode 100644 index 000000000..a1c3ab4d0 --- /dev/null +++ b/Klausuren/Sda1/Papier/Code/.gitignore @@ -0,0 +1,4 @@ +/target/ +/.settings/ +.classpath +.project diff --git a/Klausuren/Sda1/Papier/Code/Xsd/bingo.xml b/Klausuren/Sda1/Papier/Code/Xsd/bingo.xml new file mode 100644 index 000000000..d27d0c50a --- /dev/null +++ b/Klausuren/Sda1/Papier/Code/Xsd/bingo.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<top xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="test.xsd"> + <value/> +</top> \ No newline at end of file diff --git a/Klausuren/Sda1/Papier/Code/Xsd/test.xsd b/Klausuren/Sda1/Papier/Code/Xsd/test.xsd new file mode 100644 index 000000000..a85cbeda9 --- /dev/null +++ b/Klausuren/Sda1/Papier/Code/Xsd/test.xsd @@ -0,0 +1,13 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> + <xs:element name="top"> + <xs:complexType> + <xs:sequence> + <xs:element name="value"> + <xs:complexType> + <xs:attribute name="reference" type="xs:IDREF" use="required"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema> diff --git a/Klausuren/Sda1/Papier/Code/jdomException.txt b/Klausuren/Sda1/Papier/Code/jdomException.txt new file mode 100644 index 000000000..479cd05f7 --- /dev/null +++ b/Klausuren/Sda1/Papier/Code/jdomException.txt @@ -0,0 +1,8 @@ +Exception in thread "main" org.jdom2.IllegalAddException: The Content already has an + existing parent "Book" + at org.jdom2.ContentList.checkPreConditions(ContentList.java:211) + at org.jdom2.ContentList.add(ContentList.java:244) + at org.jdom2.ContentList.add(ContentList.java:79) + at java.util.AbstractList.add(AbstractList.java:108) + at org.jdom2.Element.addContent(Element.java:917) + at papier.klausur.Careless.main(Careless.java:31) diff --git a/Klausuren/Sda1/Papier/Code/pom.xml b/Klausuren/Sda1/Papier/Code/pom.xml new file mode 100644 index 000000000..cbc5e2c70 --- /dev/null +++ b/Klausuren/Sda1/Papier/Code/pom.xml @@ -0,0 +1,88 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>papier</groupId> + <artifactId>klausur</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>klausur</name> + + <url>http://www.mi.hdm-stuttgart.de/freedocs/topic/de.hdm_stuttgart.mi.lectures/sd1SectUsingMaven.html</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.6</version> + </dependency> + + <!-- https://mvnrepository.com/artifact/org.jdom/jdom2 --> + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom2</artifactId> + <version>2.0.6</version> + </dependency> + + + </dependencies> + + <build> + <plugins> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.5.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.10.3</version> + <configuration /> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.4.3</version> + <configuration> + <transformers> + <transformer + implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <manifestEntries> + <Main-Class>papier.klausur.App</Main-Class> + </manifestEntries> + </transformer> + </transformers> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + </execution> + </executions> + </plugin> + + </plugins> + </build> +</project> diff --git a/Klausuren/Sda1/Papier/Code/src/main/java/papier/klausur/App.java b/Klausuren/Sda1/Papier/Code/src/main/java/papier/klausur/App.java new file mode 100644 index 000000000..832293c5a --- /dev/null +++ b/Klausuren/Sda1/Papier/Code/src/main/java/papier/klausur/App.java @@ -0,0 +1,44 @@ +package papier.klausur; + +import java.io.IOException; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jdom2.Element; +import org.jdom2.output.Format; +import org.jdom2.output.XMLOutputter; + + +/** + * A simple http://logging.apache.org/log4j/2.x demo, + * see file log4j2.xml for configuration options. + * + */ +public class App { + private static Logger log = LogManager.getLogger(App.class); + + /** + * @param args Unused + * @throws IOException + */ + public static void main( String[] args ) throws IOException { + final Element top = new Element("top"); + + final Element address = insertHelper(top, "address"); + insertHelper(address, "street", "Vanguard road"); + insertHelper(address, "town", "Mill City"); + + new XMLOutputter(Format.getPrettyFormat()).output(top, System.out); + } + static Element insertHelper (final Element parent, String name) { + Element child = new Element(name); + parent.addContent(child); + return child; + } + static Element insertHelper (final Element parent, String name, String content) { + Element child = new Element(name); + child.addContent(content); + parent.addContent(child); + return child; + } +} diff --git a/Klausuren/Sda1/Papier/Code/src/main/java/papier/klausur/Careless.java b/Klausuren/Sda1/Papier/Code/src/main/java/papier/klausur/Careless.java new file mode 100644 index 000000000..e3b3e1ea7 --- /dev/null +++ b/Klausuren/Sda1/Papier/Code/src/main/java/papier/klausur/Careless.java @@ -0,0 +1,35 @@ +package papier.klausur; + +import java.io.IOException; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jdom2.Element; +import org.jdom2.output.Format; +import org.jdom2.output.XMLOutputter; + + +/** + * A simple http://logging.apache.org/log4j/2.x demo, + * see file log4j2.xml for configuration options. + * + */ +public class Careless { + private static Logger log = LogManager.getLogger(Careless.class); + + /** + * @param args Unused + * @throws IOException + */ + public static void main( String[] args ) throws IOException { + final Element book = new Element("Book"), + title = new Element("title"), + chapter = new Element("chapter"); + title.addContent("New Horizons"); + book.addContent(title); + book.addContent(chapter); + chapter.addContent(title); + + new XMLOutputter(Format.getPrettyFormat()).output(book, System.out); + } +} diff --git a/Klausuren/Sda1/Papier/Code/src/main/resources/log4j2.xml b/Klausuren/Sda1/Papier/Code/src/main/resources/log4j2.xml new file mode 100644 index 000000000..69f9f0f2e --- /dev/null +++ b/Klausuren/Sda1/Papier/Code/src/main/resources/log4j2.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + <Appenders> + <File name="A1" fileName="A1.log" append="false"> + <PatternLayout pattern="%t %-5p %c{2} - %m%n"/> + </File> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/> + </Console> + </Appenders> + <Loggers> + + <!-- You my want to define class or package level per-logger rules --> + <Logger name="papier.klausur.App" level="debug"> + <AppenderRef ref="A1"/> + </Logger> + <Root level="info"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/Klausuren/Sda1/Papier/Code/src/test/java/papier/klausur/AppTest.java b/Klausuren/Sda1/Papier/Code/src/test/java/papier/klausur/AppTest.java new file mode 100644 index 000000000..accf73963 --- /dev/null +++ b/Klausuren/Sda1/Papier/Code/src/test/java/papier/klausur/AppTest.java @@ -0,0 +1,17 @@ +package papier.klausur; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest { + /** + * Dummy test method + */ + @Test + public void testApp() { + Assert.assertTrue( true ); + } +} diff --git a/Klausuren/Sda1/Papier/bonus.tex b/Klausuren/Sda1/Papier/bonus.tex new file mode 100644 index 000000000..0772b495a --- /dev/null +++ b/Klausuren/Sda1/Papier/bonus.tex @@ -0,0 +1,17 @@ +\section{Bonus project (Pseudo question)} + +\begin{klausuraufgabe}{8} + + \begin{itemize} + \item [\fbox{\rule{1ex}{0em}\rule{0em}{1ex}}] I've participated in an bonus project and expect to gain related points. + \item [\fbox{\rule{1ex}{0em}\rule{0em}{1ex}}] I did not participate in any bonus project. + +\end{itemize} + +\end{klausuraufgabe} +\newpage +%%% Local Variables: +%%% mode: latex +%%% TeX-master: "113305" +%%% End: + diff --git a/Klausuren/Sda1/Papier/hinweis.tex b/Klausuren/Sda1/Papier/hinweis.tex new file mode 100644 index 000000000..79f4077a4 --- /dev/null +++ b/Klausuren/Sda1/Papier/hinweis.tex @@ -0,0 +1,15 @@ +{\Large +\textbf{Hinweis}: Sie benötigen kein zusätzliches Papier: Nutzen Sie bitte die vorhandenen Extraseiten +am Klausurende, notfalls auch die Rückseiten der Aufgabenblätter. + +In jeder Aufgabe finden Sie einen freien Rahmen zum Eintragen Ihrer Lösung. + +Sie haben mit 23 Punkten bestanden, ab 46 Punkten erhalten Sie die Note 1,0. +} + + + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: "113305" +%%% End: diff --git a/Klausuren/Sda1/Papier/jdom.tex b/Klausuren/Sda1/Papier/jdom.tex new file mode 100644 index 000000000..32d18f072 --- /dev/null +++ b/Klausuren/Sda1/Papier/jdom.tex @@ -0,0 +1,25 @@ +\section{Jdom output} + +Consider the following code: + +{\footnotesize% + \lstinputlisting[language=Java, firstline=24, lastline=43]{Code/src/main/java/papier/klausur/App.java} + } + + +\begin{klausuraufgabe}{12} + + Write down the resulting XML output. + +\fbox{\parbox[t]{\textwidth}{\rule{0mm}{80mm}}} +\end{klausuraufgabe} +\newpage + + + + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: "113305" +%%% End: + diff --git a/Klausuren/Sda1/Papier/jdomerror.tex b/Klausuren/Sda1/Papier/jdomerror.tex new file mode 100644 index 000000000..75e54675b --- /dev/null +++ b/Klausuren/Sda1/Papier/jdomerror.tex @@ -0,0 +1,31 @@ +\section{Jdom Exception} + +Consider the following code in class \texttt{papier.klausur.Careless}: + +{\footnotesize% + \lstset{numbers=left} + \lstinputlisting[language=Java, numberstyle=\bf, firstnumber=24, firstline=24, lastline=34]{Code/src/main/java/papier/klausur/Careless.java} + } + +This yields the following Exception: +{\footnotesize% + \lstinputlisting{Code/jdomException.txt} + } + + +\begin{klausuraufgabe}{12} + + Explain this Exception's cause. + +\fbox{\parbox[t]{\textwidth}{\rule{0mm}{80mm}}} +\end{klausuraufgabe} +\newpage + + + + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: "113305" +%%% End: + diff --git a/Klausuren/Sda1/Papier/prepared.tex b/Klausuren/Sda1/Papier/prepared.tex new file mode 100644 index 000000000..0cb6cf834 --- /dev/null +++ b/Klausuren/Sda1/Papier/prepared.tex @@ -0,0 +1,15 @@ +\section{\texttt{PreparedStatement} vs. \texttt{Statement}} + +\begin{klausuraufgabe}{10} + +State two advantages when using \texttt{java.sql.PreparedStatement} in favour of ordinary \texttt{java.sql.} \texttt{Statement} +instances. + +\fbox{\parbox[t]{\textwidth}{\rule{0mm}{80mm}}} +\end{klausuraufgabe} +\newpage +%%% Local Variables: +%%% mode: latex +%%% TeX-master: "113305" +%%% End: + diff --git a/Klausuren/Sda1/Papier/xsd.tex b/Klausuren/Sda1/Papier/xsd.tex new file mode 100644 index 000000000..374bbc51f --- /dev/null +++ b/Klausuren/Sda1/Papier/xsd.tex @@ -0,0 +1,32 @@ +\section{Valid document instance} + +Consider the following schema: + +{\footnotesize% +\lstinputlisting[language=Xml]{Code/Xsd/test.xsd} +} + +\begin{klausuraufgabe}{12} + +Is it possible to provide a valid instance? Explain your answer. + +Hint from documentation: + +\begin{itemize} +\item IDREF attribute values must conform to the EBNF for "`Name"'. In simple terms this means a "`Name"' has to start with a letter or ':' or '\_'. + The rest of the characters must be numbers, letters ':', '\_', '-', or '.' it can not contain any spaces. + \item The value of the IDREF attribute has to match an ID value defined elsewhere within the XML Document. +\end{itemize} + +\fbox{\parbox[t]{\textwidth}{\rule{0mm}{80mm}}} +\end{klausuraufgabe} +\newpage + + + + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: "113305" +%%% End: + -- GitLab