From f5315d72aebdad9e9a06a93bf8166a3050296815 Mon Sep 17 00:00:00 2001 From: mlabusch Date: Fri, 16 Jun 2017 11:25:59 +0200 Subject: [PATCH] [Fix]: Include Traffic Light into Mosh --- changes_to_monolith/HomepageController.java | 45 ---------------- changes_to_monolith/product.html | 53 ------------------- .../microservice_stock/chapter/Header.tex | 2 +- .../microservice_stock/chapter/Struktur.tex | 40 ++++++++++++-- 4 files changed, 36 insertions(+), 104 deletions(-) delete mode 100644 changes_to_monolith/HomepageController.java delete mode 100644 changes_to_monolith/product.html diff --git a/changes_to_monolith/HomepageController.java b/changes_to_monolith/HomepageController.java deleted file mode 100644 index 19d0aea..0000000 --- a/changes_to_monolith/HomepageController.java +++ /dev/null @@ -1,45 +0,0 @@ -package de.mstock.monolith.web; - -import java.util.Locale; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import de.mstock.monolith.service.ShopService; - -@Controller -public class HomepageController { - - private static final String TEMPLATE = "homepage"; - - @Autowired - private ShopService shopService; - private final String STOCKADMINFRONTENDTEMPLATE = "https://stock.pub.warehost.de/index.html"; - - /** - * Redirect - * - * @param model Template model - * @return The constant template name for the stock admin frontend. - */ - @RequestMapping(value = "/stockadmin", method = RequestMethod.GET) - public String redirect(Model model) {return "redirect:"+ this.STOCKADMINFRONTENDTEMPLATE; - } - - /** - * Homepage - * - * @param model Template model - * @param locale Current locale - * @return The template's name. - */ - @RequestMapping(value = "/", method = RequestMethod.GET) - public String homepage(Model model, Locale locale) { - model.addAttribute("categories", shopService.getCategories(locale)); - return TEMPLATE; - } - -} \ No newline at end of file diff --git a/changes_to_monolith/product.html b/changes_to_monolith/product.html deleted file mode 100644 index 968f4a8..0000000 --- a/changes_to_monolith/product.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - -
-
- -
-
- -
- -
-
- Generic placeholder image -
- - [[#{general.sampleImage}]]: Rach. New Packaging. CC BY 2.0 - -
-
-
-

Product Name

- -

0,00 Euro

-

Description.

-
-
-
- -
-

© 2017

-
- -
- - - - - - \ No newline at end of file diff --git a/documentation/microservice_stock/chapter/Header.tex b/documentation/microservice_stock/chapter/Header.tex index 9aae92c..c1a9459 100644 --- a/documentation/microservice_stock/chapter/Header.tex +++ b/documentation/microservice_stock/chapter/Header.tex @@ -31,7 +31,7 @@ % ---- Farben ----------------------------------------------------------------------------------------------- \definecolor{listings}{RGB}{226,226,226} - +\StopCensoring \definecolor{hs-blau}{RGB}{10,85,140} \definecolor{hs-tuerkis}{RGB}{50,180,200} \definecolor{hs-rot}{RGB}{195,5,50} diff --git a/documentation/microservice_stock/chapter/Struktur.tex b/documentation/microservice_stock/chapter/Struktur.tex index f2480ff..9a3d3e3 100644 --- a/documentation/microservice_stock/chapter/Struktur.tex +++ b/documentation/microservice_stock/chapter/Struktur.tex @@ -126,7 +126,14 @@ Neben den bisherigen Packages, die bereits Whitebox-Tests umfassen, ist in dem P \subsection{Anpassung des Monolithen} \label{subsec: Anpassung des Monolithen} -Damit der Microservice Warenwirtschaft durch den bestehenden Monolithen des Webshops Mosh genutzt werden kann, wurden hier die nachfolgend aufgeführten Änderungen vorgenommen. Zunächst wurde für den Aufruf des Admin-Frontends über die URL des Monolithen \texttt{/stockadmin} das nachfolgende Mapping in der Java-Datei \texttt{HomepageController.java} ergänzt. +Damit der Microservice Warenwirtschaft durch den bestehenden Monolithen des Webshops Mosh genutzt werden kann, wurden hier die nachfolgend aufgeführten Änderungen vorgenommen. +\begin{itemize} + \item Anpassung der \texttt{HomepageController.java}, sodass der Microservice Warenwirtschaft über die URL des Monolithen mit der Erweiterung \texttt{/stockadmin} aufgerufen werden kann + \item Einfügen der Ampeldarstellung für die Verfügbarkeit auf den Produktseiten unter \texttt{products.html} + \item Anpassung der \texttt{ProductDTO.java} um die Rückgabe der Produkt-ID, sodass diese für die Ampeldarstellung abgerufen werden kann + \item Anpassung der \texttt{DataTransferObjectFactory.java} um die Rückgabe der Produkt-ID, sodass diese für die Ampeldarstellung abgerufen werden kann + \item Anpassung der \texttt{ProductController.java} um eine JSON-Schnittstelle +\end{itemize} \begin{lstlisting}[caption=Anpassung in HomepageController.java, language=Java] private final String STOCKADMINFRONTENDTEMPLATE = "https://stock.pub.warehost.de/index.html"; @@ -137,7 +144,7 @@ private final String STOCKADMINFRONTENDTEMPLATE = "https://stock.pub.warehost.de } \end{lstlisting} -Weiter wurde die Ampeldarstellung der Verfügbarkeit unter \texttt{products.html} eingefügt. Hierfür wurde das \texttt{ProductDTO.java} um die Rückgabe der Produkt-ID erweitert. +\texttt{ProductDTO.java} um die Rückgabe der Produkt-ID erweitert. \begin{lstlisting}[caption=Anpassung products.html, language=HTML]
@@ -152,10 +159,33 @@ Weiter wurde die Ampeldarstellung der Verfügbarkeit unter \texttt{products.html \end{lstlisting} - \begin{lstlisting}[caption=Anpassung ProductDTO.java, language=Java] - - +public class ProductDTO { + private int id; + [...] + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } \end{lstlisting} +\begin{lstlisting}[caption=Anpassung DataTransferObjectFactory.java, language=Java] + +private ProductDTO createProductWithoutReviewsDTO(Product product, Locale locale, + [...] + productDTO.setId(product.getId()); + [...] +}\end{lstlisting} + + +\begin{lstlisting}[caption=Anpassung ProductControlle.java, language=Java] +@RequestMapping(value = "/products/{prettyUrlFragment:[\\w-]+}.json", method = RequestMethod.GET) +@ResponseBody +public ProductDTO productJson(@PathVariable String prettyUrlFragment, Locale locale) { +return shopService.getProduct(locale, prettyUrlFragment); +} +}\end{lstlisting}