Finito restaurant lato server
This commit is contained in:
parent
06db6b8d8a
commit
e15a5182f2
2 changed files with 135 additions and 3 deletions
BIN
italian.pdf
BIN
italian.pdf
Binary file not shown.
138
main.tex
138
main.tex
|
@ -35,7 +35,7 @@
|
|||
\end{en}
|
||||
\def\mdauthor{Claudio Maggioni}
|
||||
\def\mddate{\today}
|
||||
\def\mdrevision{5}
|
||||
\def\mdrevision{6}
|
||||
|
||||
% header and footer style
|
||||
\clearscrheadfoot
|
||||
|
@ -281,9 +281,9 @@
|
|||
di successo che in errore.
|
||||
\end{itemize}
|
||||
|
||||
Seguono le interfaccie delle classi \textit{CRUDUtils}, \textit{JsonProducer},
|
||||
Seguono le interfacce delle classi \textit{CRUDUtils}, \textit{JsonProducer},
|
||||
\textit{ReadableRESTController} e \textit{CRUDRESTController}, complete di
|
||||
Javadoc.
|
||||
Javadoc (in inglese, come presente nei sorgenti originali).
|
||||
\end{it}
|
||||
|
||||
\begin{lstlisting}[caption=Interfaccia della classe \textit{JsonProducer}, label={lst:jsonprd-java}, language=Java]
|
||||
|
@ -505,6 +505,138 @@ public abstract class CRUDRESTController<T extends CRUDable, U extends
|
|||
}
|
||||
\end{lstlisting}
|
||||
|
||||
\begin{it}
|
||||
Si precisa che la classe \textit{CRUDable} è un estensione della classe
|
||||
\textit{Readable} che contiene metodi per l'inizializzazione dell'oggetto
|
||||
sulla base di dati in input, contenuti in \textit{MultivaluedMap<String,
|
||||
String>}. Di conseguenza, le classi ``entità'' che estendono CRUDable
|
||||
possono essere usate per operazioni di scrittura, come quelle implementate
|
||||
da \textit{CRUDRESTController}.
|
||||
\end{it}
|
||||
|
||||
\begin{lstlisting}[caption=Interfaccia della classe \textit{CRUDUtils}, label={lst:crudutils-java}, language=Java]
|
||||
|
||||
/**
|
||||
* Database access class. Access statically
|
||||
*/
|
||||
public abstract class CRUDUtils {
|
||||
|
||||
/**
|
||||
* Interface containing a function able to generate an Hibernate Query
|
||||
* object and execute it by getting a generic response given the
|
||||
* session
|
||||
*
|
||||
* @param <T> the response type
|
||||
*/
|
||||
public interface HBMInteraction<T> {
|
||||
T execute(Session s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface containing a function able to generate an Hibernate Query
|
||||
* object and execute it by getting a list of rows given the session
|
||||
*/
|
||||
public interface HBMQuery extends HBMInteraction<List<Object[]>> {
|
||||
List<Object[]> execute(Session s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of items on a single page. Used when pagination is requested
|
||||
*/
|
||||
public static final int ITEMSPERPAGE = %*\ldots*);
|
||||
|
||||
%*\ldots*)
|
||||
|
||||
private static final Logger log = %*\ldots*);
|
||||
|
||||
/**
|
||||
* Save a writable entity on the database
|
||||
*
|
||||
* @param o the entity to save
|
||||
* @param <T> type of the entity. Must be readable and writable
|
||||
* @return boolean true = success, false = error
|
||||
*/
|
||||
public static <T extends CRUDable> boolean persist(final T o) { %*\ldots*) }
|
||||
|
||||
/**
|
||||
* Delete a writable entity on the database
|
||||
*
|
||||
* @param toDelete the entity to delete
|
||||
* @param <T> type of the entity. Must be readable and writable
|
||||
* @return boolean true = success, false = error
|
||||
*/
|
||||
public static <T extends CRUDable> boolean delete(final T toDelete)
|
||||
{ %*\ldots*) }
|
||||
|
||||
%*\ldots*)
|
||||
|
||||
/**
|
||||
* Execute a query which returns data of a generic type
|
||||
*
|
||||
* @param query HBMInteraction implementation
|
||||
* @param <T> The returning type
|
||||
* @return the data
|
||||
*/
|
||||
public static <T> T executeHBMInteraction(HBMInteraction<T> query)
|
||||
{ %*\ldots*) }
|
||||
|
||||
/**
|
||||
* Get a list of entities
|
||||
*
|
||||
* @param tClass class of the entities
|
||||
* @param restrictions map of names of fields and their values which
|
||||
* must be equal in the fetched entities
|
||||
* (null accepted if not used)
|
||||
* @param criteria list of additional filters (Hibernate Criterion
|
||||
* objects, null accepted if not used)
|
||||
* @param <T> entity type. Must be readable
|
||||
* @param o order of the entities (Hibernate Order, null accepted if
|
||||
* not used)
|
||||
* @param page the page number to fetch (starts at 1, null accepted if
|
||||
* not used)
|
||||
* @return the list of entities
|
||||
*/
|
||||
public static <T extends Readable> List<T> get(Class<T> tClass,
|
||||
Map<String, Object> restrictions, List<Criterion> criteria,
|
||||
Order[] o, Integer page) { %*\ldots*) }
|
||||
|
||||
/**
|
||||
* Get a list of entities
|
||||
*
|
||||
* @param tClass class of the entities
|
||||
* @param <T> entity type. Must be readable
|
||||
* @return the list of entities
|
||||
*/
|
||||
public static <T extends Readable> List<T> get(Class<T> tClass) { %*\ldots*) }
|
||||
|
||||
|
||||
/**
|
||||
* Get a single entity
|
||||
*
|
||||
* @param tClass class of the entities
|
||||
* @param restrictions map of names of fields and their values which
|
||||
* must be equal in the fetched entities
|
||||
* (null accepted if not used)
|
||||
* @param <T> entity type. Must be readable
|
||||
* @return the list of entities
|
||||
*/
|
||||
public static <T extends Readable> T getOne(Class<T> tClass,
|
||||
Map<String, Object> restrictions) { %*\ldots*) }
|
||||
|
||||
/**
|
||||
* Get a single entity
|
||||
*
|
||||
* @param tClass class of the entities
|
||||
* @param pk the primary key object of the entity
|
||||
* @param <T> entity type. Must be readable and contain a primary key
|
||||
* object
|
||||
* @return the list of entities
|
||||
*/
|
||||
public static <T extends Readable> T getOne(Class<T> tClass,
|
||||
PrimaryKey<T> pk) { %*\ldots*) }
|
||||
}
|
||||
\end{lstlisting}
|
||||
|
||||
\begin{it}
|
||||
Oltre a quanto mostrato, \textit{restaurant} contiene vari metodi utilità per
|
||||
la gestione di file \texttt{.properties}, per la validazione dei dati in
|
||||
|
|
Reference in a new issue