\documentclass[11pt]{article}
\include{settings}

\begin{document}
	\createTitlepage{Deliverable 1 : Analysis of the legacy application}
	
	\section{Start and test of the Webshop functionality}
	The initial version of the legacy Webshop was exported as an \texttt{Eclipse}-Project and hence not compatible with other IDEs like \texttt{IntelliJ}. Other IDEs did not properly recognize the folder structure, especially the property and resource files were located in the wrong folder, so the legacy app did only partially work. On the other hand the team decide that it did not want to host a native \texttt{MySQL} database.
	
	So the decision taken to wrap the database and the Webshop into two separate \texttt{Docker} containers which communicate between each other on the same host. The team also wanted to gain experience with \texttt{Docker} containers and simplify the build process.

	The build and configuration (\texttt{MySQL} and \texttt{Tomcat}) of the whole system was wrapped in shell script shown in Figure~\ref{fig:legacy-sh}.
	\cgraphic{0.8\textwidth}{legacy-sh}{run\_legacy.sh}
	
	As described in the script, it initializes the database with a schema and user as well as the user for the \texttt{Tomcat} webserver. So the management console can be easily accessed. The project can be found \href{https://github.com/mavogel/vis-lab}{here} on \texttt{github}.
	
	\section{Analysis of the source code}
    In this section the architecture and behavior of the legacy Webshop is described by the use of \texttt{UML} and class/sequence diagrams.
    
    \subsection{Product management} % Felix
	The central module in product management are the classes \texttt{ProductManager} and \texttt{ProductManagerImpl}. Whenever a user action requires information concerning products, a method of this model will be invoked by the controller. The model does not directly use the database. It uses a Hibernate \textit{Data Access Object} for dealing with persistence tasks.

	\sfigTwo{products/list}{Listing products}{products/details}{Listing product details}{Displaying products}{displaying-products}
    When the user logs in, they have several options. One of them is listing all products using the \texttt{ListAll\-ProductsAction}.
		
	For every product in the list, there is the possibility of showing its details. This action is being handled in the class \texttt{ProductDetailsAction}.
	
	Admins have additional possibilities. They are allowed to add/delete products and create/delete categories that products belong to.
	\sfigTwo{products/createproduct}{Create a product}{products/deleteproduct}{Delete a product}{Modifying products}{modify-products}	
	
	The \texttt{DeleteCategoryAction} works just like the action used to delete a product, but it invokes the \texttt{CategoryDAO} instead of the product access object.
    \cgraphic{0.5\textwidth}{products/addcategory}{Add a category}
    
    \newpage
    \subsection{Search} % Manu
   \sfigTwo{searchAction-seq}{Search sequence diagram}{searchAction-class}{SearchAction class diagram}{Search Actions}
   The process of searching for a product with a given criteria is displayed in Figure~\ref{fig:searchAction-seq}. It can only be performed if the user is logged in. If all search fields are left empty, all products of all categories are displayed. If the search text field has a value, the products with the given text search values are looked up. \textbf{Note:} the search is performed as a \textit{like}-search only on the descriptions of the products and not the title. If no search text but and one or more criteria, only the criteria are considered in the search. Furthermore if a criteria is left empty, its minimum or maximum value is considered.
   
   Searching for a product is performed as follows: 
   \begin{enumerate}
   	\item The \texttt{SearchAction} uses the \texttt{ProductManagerImpl} to retrieve products for the given search values.
   	\item The \texttt{ProductManagerImpl} uses the \texttt{ProductDAO} to access the products in database layer.
   	\item The \texttt{ProductDAO} creates and performs the search query using the given search text and criteria for finding the desired products.
   	\item As a last step all categories are loaded for displaying next to the product.
   \end{enumerate}
   
   The class diagram of the SearchAction is displayed in Figure~\ref{fig:searchAction-class}.
   
   \subsection{User management} %Lin
   \cgraphic{0.7\textwidth}{user-management}{User management sequence diagram} 
    The activity diagram for user management is displayed in Figure~\ref{fig:user-management}. The new user can self register with own information. Of cause be able to edit their profile. Only the administrator can create the role (admin, user ..). The administrator can search the user via username or role.
    
    \begin{enumerate}
    	\item The \texttt{registerUser} Action(create user) will check whether the username already exist, if not then create a new user with username, name, lastname, password, role using the \texttt{UserDAO} and \texttt{RoleDAO}.
    	\item The Actor can get a user by username in \texttt{UserDAO}. Equally can get a user or users by RoleLevel(admin, user..) 
    \end{enumerate}
      
\end{document}
