diff --git a/italian.pdf b/italian.pdf index 9a1c4a3..4f89e53 100644 Binary files a/italian.pdf and b/italian.pdf differ diff --git a/main.tex b/main.tex index 8ec9e5c..4291193 100644 --- a/main.tex +++ b/main.tex @@ -6,6 +6,7 @@ \end{en} \usepackage{blindtext} +\usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[pdftex]{graphicx} \usepackage{scrlayer-scrpage} @@ -15,6 +16,8 @@ \usepackage[backend=biber]{biblatex} \usepackage{pgfgantt} \usepackage{pgffor} +\usepackage{listings} +\usepackage{lmodern} \bibliography{bibliography} @@ -42,6 +45,21 @@ \ihead[]{\mdtitle} \cfoot[\pagemark]{\pagemark} +% listings configuration +\begin{it} + \renewcommand{\lstlistingname}{Listato} + \renewcommand{\lstlistlistingname}{Lista dei listati} +\end{it} +\lstset{ + basicstyle=\small\ttfamily, + frame=shadowbox, + rulesepcolor=\color{black}, + columns=fullflexible, + commentstyle=\color{gray}, + keywordstyle=\bfseries, + escapeinside={\%*}{*)} +} + \begin{document} % first page @@ -216,6 +234,206 @@ \begin{it} \subsubsection{\textit{restaurant} -- lato server} +\begin{lstlisting}[caption=Interfaccia della classe \textit{JsonProducer}, label=jsonprd-java, language=Java] +/** + * Something that generates JSON responses + */ +public abstract class JsonProducer { + + protected static final Logger log = %*\ldots*); + + protected static final Gson GSON; + + /** + * Generates a json response with status 200 containing an object + * + * @param o the contents of the response + * @return JSON response + */ + protected Response jsonResponse(Object o) { %*\ldots*) } + + /** + * Generates a json response with custom status containing an object + * + * @param o the contents of the response + * @param status status of the response + * @return JSON response + */ + protected Response jsonResponse(Object o, int status) { %*\ldots*) } + + /** + * Generates a json response containing a library standard error + * + * @param error the error + * @return JSON error response + */ + protected Response jsonErrResponse(Error error) { %*\ldots*) } + + /** + * Generates a json response containing a custom error + * + * @param error the error + * @return JSON error response + */ + protected Response jsonErrResponse(ErrorDetails error) { %*\ldots*) } + + /** + * Generates an error response if the parameter given as argument + * is null or an empty string + * + * @param s parameter + * @param propName parameter name, used in the error description + * @return JSON error response or null if the parameter is valid + */ + protected Response require(Object s, String propName) { %*\ldots*) } +} +\end{lstlisting} +\begin{lstlisting}[caption=Interfaccia della classe \textit{ReadableRESTController}, label=rdbrest-java, language=Java] +/** + * A REST Controller only readable + * @param The readable entity class + */ +public abstract class ReadableRESTController> extends JsonProducer { + + /** + * Interface used to carry a function capable of filtering a list + * of entities after it has been retrieved from the database + * + * @param The readable entity class + */ + public interface ListFilter { + List filter(List toFilter); + } + + /** + * Returns the class of the readable entity. Used as parameter for + * CRUDUtils + * + * @return the class of the readable entity + */ + protected abstract Class getBeanClass(); + + protected final Logger log = %*\ldots*); + + /** + * Returns a response with a standard unfiltered, unpaginated list + * of entities + * + * @return JSON response, success or not + */ + protected Response list() { %*\ldots*) } + + /** + * Returns a list of entities, customizable in many ways + * + * @param filter map of names of fields and their values which must + * be equal in the fetched entities (null accepted if + * not used) + * @param otherFilter list of additional filters (Hibernate Criterion + * objects, null accepted if not used) + * @param order order of the entities (Hibernate Order, null accepted + * if not used) + * @param afterDb implementation of interface containing a function + * capable of filtering a list of entities (null accepted + * if not used) + * @param page the page number to fetch (starts at 1, null accepted + * if not used) + * @return JSON response, success or not + */ + protected Response list(Map filter, + List otherFilter, Order order, + ListFilter afterDb, Integer page) { %*\ldots*) } + + /** + * Returns a response with a single entity given its primary key + * + * @param filterOne map of names of columns and their values containing + * the primary key + * @return JSON response, success or not + */ + protected Response get(Map filterOne) { %*\ldots*) } + + /** + * Returns a response with a single entity given its primary key + * + * @param pk the primary key + * @return JSON response, success or not + */ + protected Response get(PrimaryKey pk) { %*\ldots*) } + + /** + * Returns the existing primary keys given a set of primary keys sent + * as a JSON array + * + * @param requestBody the request body with JSON data + * @return JSON array of the existing primary keys or error response + */ + protected Response existing(InputStream requestBody) { %*\ldots*) } +} +\end{lstlisting} +\begin{lstlisting}[caption=Interfaccia della classe \textit{CRUDRESTController}, label=crudrest-java, language=Java] +/** + * A REST Controller readable and writable + * @param The readable and writable entity class + */ +public abstract class CRUDRESTController> extends ReadableRESTController { + + /** + * A standard edit route body. Edits an entity and returns a JSON + * response, both on success and on error. + * + * @param filterOne map containing columns and relative values of the + * primary key of the entity to edit + * @param form request data containing the fields to edit + * @return JSON response, positive or negative + */ + protected Response edit(Map filterOne, + MultivaluedMap form) { %*\ldots*) } + + /** + * A standard edit route body. Edits an entity and returns a JSON + * response, both on success and on error. + * + * @param pKey the entity primary key + * @param form request data containing the fields to edit + * @return JSON response, positive or negative + */ + protected Response edit(PrimaryKey pKey, + MultivaluedMap form) { %*\ldots*) } + + /** + * A standard delete route body. Deletes an entity and returns a JSON + * response, both on success and on error. + * + * @param pKey the entity primary key + * @return JSON response, positive or negative + */ + protected Response delete(PrimaryKey pKey) { %*\ldots*) } + + /** + * A standard delete route body. Deletes an entity and returns a JSON + * response, both on success and on error. + * + * @param filterOne map containing columns and relative values of the + * primary key of the entity to delete + * @return JSON response, positive or negative + */ + protected Response delete(Map filterOne) { %*\ldots*) } + + /** + * A standard create route body. Creates an entity and returns a JSON + * response, both on success and on error. + * + * @param form request data containing the entity column values + * @return JSON response, positive or negative + */ + protected Response create(MultivaluedMap form) { %*\ldots*) } + + %*\ldots*) +} +\end{lstlisting} \end{it} \begin{it} @@ -425,6 +643,7 @@ Le fasi del progetto, di cui le date di inizio e di fine sono indicate nel diagr \pagenumbering{gobble} \listoffigures +\lstlistoflistings \printbibliography \end{document}