From 950fa813137457ae3fd9a944efce07cde4efd99b Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Thu, 15 Dec 2016 11:43:34 +0100 Subject: [PATCH] Getting started with MongoDB --- Doc/Common/glossary.xml | 9 ++++ Doc/Sda1/mongodb.xml | 49 +++++++++++++++++++ P/Sda1/Mongostart/.gitignore | 5 ++ P/Sda1/Mongostart/pom.xml | 21 ++++++++ .../mi/sda1/mongostart/Driver.java | 19 +++++++ .../Mongostart/src/main/resources/log4j2.xml | 21 ++++++++ .../mi/sda1/mongotest/TestMongo.java | 12 +++++ 7 files changed, 136 insertions(+) create mode 100644 Doc/Sda1/mongodb.xml create mode 100644 P/Sda1/Mongostart/.gitignore create mode 100644 P/Sda1/Mongostart/pom.xml create mode 100644 P/Sda1/Mongostart/src/main/java/de/hdm_stuttgart/mi/sda1/mongostart/Driver.java create mode 100644 P/Sda1/Mongostart/src/main/resources/log4j2.xml create mode 100644 P/Sda1/Mongostart/src/test/java/de/hdm_stuttgart/mi/sda1/mongotest/TestMongo.java diff --git a/Doc/Common/glossary.xml b/Doc/Common/glossary.xml index 695f6de3d..6b945b6fb 100644 --- a/Doc/Common/glossary.xml +++ b/Doc/Common/glossary.xml @@ -599,6 +599,15 @@ version control system</link></para> </glossdef> </glossentry> + + <glossentry xml:id="glo_Ubuntu"> + <glossterm><productname>Ubuntu</productname></glossterm> + + <glossdef> + <para><link xlink:href="https://www.ubuntu.com">Linux + Distribution</link></para> + </glossdef> + </glossentry> </glosslist> </glossdef> </glossentry> diff --git a/Doc/Sda1/mongodb.xml b/Doc/Sda1/mongodb.xml new file mode 100644 index 000000000..06e8f90f3 --- /dev/null +++ b/Doc/Sda1/mongodb.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<chapter version="5.0" xml:id="sda1ChapMongoDB" + xmlns="http://docbook.org/ns/docbook" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:xi="http://www.w3.org/2001/XInclude" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:m="http://www.w3.org/1998/Math/MathML" + xmlns:html="http://www.w3.org/1999/xhtml" + xmlns:db="http://docbook.org/ns/docbook"> + <title><productname>MongoDB</productname></title> + + <section xml:id="sd1SectMongodbPrerequisite"> + <title>Prerequisites</title> + + <para><xref linkend="glo_Ubuntu"/> installation instructions are on offer + from <uri + xlink:href="https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#run-mongodb-community-edition">https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu</uri>.</para> + + <para>Follow <uri + xlink:href="https://docs.mongodb.com/getting-started/shell/introduction">https://docs.mongodb.com/getting-started/shell/introduction</uri> + populating your database with sample data. Insert, retrieve, update and + delete sample data like e.g.:</para> + + <programlisting language="json">db.courses.insert( + { + "lecture" : { + "title" : "Introduction to JSON", + "required" : "10075", + "prerequisites" : "XXX" + }, + "studyCourse" : "MIB", + "programme" : "Bachelor", + "recommendedSemesters" : [ + { + "semester" : [3], + "comment" : "before doing practical stuff" + }, + { + "semester" : [5,6,7], + "comment" : "After doing practical stuff" + } + ], + "lecture_id" : 113213 + } +)</programlisting> + </section> + + <xi:include href="../Common/glossary.xml" xpointer="element(/1)"/> +</chapter> diff --git a/P/Sda1/Mongostart/.gitignore b/P/Sda1/Mongostart/.gitignore new file mode 100644 index 000000000..963f79fe9 --- /dev/null +++ b/P/Sda1/Mongostart/.gitignore @@ -0,0 +1,5 @@ +/target/ +/.settings/ +.classpath +.project +A1.log \ No newline at end of file diff --git a/P/Sda1/Mongostart/pom.xml b/P/Sda1/Mongostart/pom.xml new file mode 100644 index 000000000..a7aae68b8 --- /dev/null +++ b/P/Sda1/Mongostart/pom.xml @@ -0,0 +1,21 @@ +<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> + + <parent> + <groupId>de.hdm-stuttgart.mi</groupId> + <artifactId>lecturenotes-pom</artifactId> + <version>1.0</version> + + <relativePath>../../pom.xml</relativePath> + </parent> + + <groupId>de.hdm-stuttgart.mi.sda1</groupId> + <artifactId>mongostart</artifactId> + <version>0.8</version> + <packaging>jar</packaging> + + <name>Mongostart</name> + + <url>http://www.mi.hdm-stuttgart.de/freedocs</url> + +</project> diff --git a/P/Sda1/Mongostart/src/main/java/de/hdm_stuttgart/mi/sda1/mongostart/Driver.java b/P/Sda1/Mongostart/src/main/java/de/hdm_stuttgart/mi/sda1/mongostart/Driver.java new file mode 100644 index 000000000..2fa675f13 --- /dev/null +++ b/P/Sda1/Mongostart/src/main/java/de/hdm_stuttgart/mi/sda1/mongostart/Driver.java @@ -0,0 +1,19 @@ +package de.hdm_stuttgart.mi.sda1.mongostart; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * MongoDB connection demo. + * + */ +public class Driver { + private static final Logger log = LogManager.getLogger(Driver.class); + + /** + * @param args Unused + */ + public static void main(String[] args) { + log.info("Connecting to mongodb"); + } +} diff --git a/P/Sda1/Mongostart/src/main/resources/log4j2.xml b/P/Sda1/Mongostart/src/main/resources/log4j2.xml new file mode 100644 index 000000000..885670527 --- /dev/null +++ b/P/Sda1/Mongostart/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="%C{2} (%F:%L) - %m%n"/> + </Console> + </Appenders> + <Loggers> + + <!-- You my want to define class or package level per-logger rules --> + <Logger name="de.hdm_stuttgart.mi.sda1.alignimg.App" level="warn"> + <AppenderRef ref="A1"/> + </Logger> + <Root level="warn"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/P/Sda1/Mongostart/src/test/java/de/hdm_stuttgart/mi/sda1/mongotest/TestMongo.java b/P/Sda1/Mongostart/src/test/java/de/hdm_stuttgart/mi/sda1/mongotest/TestMongo.java new file mode 100644 index 000000000..3fd00b809 --- /dev/null +++ b/P/Sda1/Mongostart/src/test/java/de/hdm_stuttgart/mi/sda1/mongotest/TestMongo.java @@ -0,0 +1,12 @@ +package de.hdm_stuttgart.mi.sda1.mongotest; + +import org.junit.Assert; +import org.junit.Test; + +public class TestMongo { + + @Test + public void start() { + Assert.assertTrue(true); + } +} \ No newline at end of file -- GitLab