diff --git a/italian.pdf b/italian.pdf index 88db83f..8134cf0 100644 Binary files a/italian.pdf and b/italian.pdf differ diff --git a/main.tex b/main.tex index a553a34..2cbb7e2 100644 --- a/main.tex +++ b/main.tex @@ -606,7 +606,7 @@ public abstract class CRUDUtils { * @param tClass class of the entities * @param entity type. Must be readable * @return the list of entities - */ + */ public static List get(Class tClass) { %*\ldots*) } @@ -647,6 +647,121 @@ public abstract class CRUDUtils { \begin{it} \subsubsection{\textit{restaurant} -- lato client} \end{it} +\begin{lstlisting}[caption=Interfaccia della classe \textit{RESTService}, label={lst:restservice-ts}, language=Java] +export class RESTService { + + ... + + /** + * Read all the pages of an entity in order to save them for offline + * readings. + * + * @param {{ new(): T }} - class of the table to read + * @param {any} - key data for the search. Must not contain filters + * or a field with key '_page' + * @return {Promise} boolean promise that resolves when the + * reading has been done, true if succesful, + * false if not + */ + public bulkRead(type: TableStatic, restrictions?: any): + Promise { ... } + + /** + * Retrieves a list of entities. When online and requested without + * filters, the list is saved in the offline storage. When offline, + * the data from the offline storage is read and filtered accordingly. + * + * Request criteria regarding directly properties of the entity MUST + * have the following format: + * + * 'attr-' + name_of_property[.nested] [+ '||' + other_property] + + * ('-like' | '-eq' | '-flag' | '-gt' | '-lt' | '-gte' | '-lte') + * + * Multiple field names separed by '||' state that the search must be + * done on multiple fields with a logic OR. + * + * The different suffixes denote different logical criteria. Look up + * the documentation of meetsCriteriaFilter*(...) methods in + * order to get detailed info on each one. + * + * @param {{ new(): T }} type - type of the table to read + * @param {number} page - number of the page starting at 1 (in offline + * mode, a 20 entities slice; in online mode, + * as defined by the server). -1 is for no + * pagination + * @param {any} restrictions - restrictions required by the server, + * and filters. + * @param {boolean} offline - whether to fetch (true) or not (false) + * offline entities to sync. Defaults to true + * @return {Promise} - promise of the expanded list, unsuccesful + * when the storage readings are unsuccesful + */ + public read(type: TableStatic, page: number, + restrictions?: any, addOffline?: boolean): Promise { ... } + + /** + * Asks to the server which entity instances of the ones + * saved in the offline storage exist and deletes the + * ones that do not exist on the server. + * + * @param {TableStatic} type - the entity type + * @return {Promise} promise rejecting only if an error occurs + */ + private async existing(type: TableStatic): Promise { ... } + + /** + * Reads a single entity, even in the offline storage if offline. + * + * @param {{ new(): T }} type - class of the entity to read + * @param {any} keyData - the primary key fields and their values + * in a JS Object, plus the 'id' field of + * type string used in the end bit of the + * request path. + * @return {Promise} - promise of the element, unsuccesful if + * not found. + */ + public readOne(type: TableStatic | string, + keyData: any): Promise { ... } + + /** + * Updates an entity on the server or, if offline, saves it in the + * offline sync queue. + * + * @param {{ new(): T }} type - class of the entity to be saved + * @param {T} value - the entity to save + * @param {any} keyData - the primary key fields and their values + * in a JS Object, plus the 'id' field of + * type string used in the end bit of the + * request path. + * @return {Promise} - promise of the saved element. + */ + public update(type: TableStatic | string, value: T, + keyData: any): Promise { ... } + + /** + * Creates an entity on the server or, if offline, saves it in the + * offline sync queue. + * + * @param {{ new(): T }} type - class of the entity to be deleted + * @param {string} id - string used in the end bit of the request path. + * @param {any} keyData - the primary key fields and their values in + * a JS Object + * @return {Promise} - promise of the element deleted + */ + public create(type: TableStatic | string, value: T): + Promise { ... } + + /** + * Deletes an entity on the server or, if offline, marks it for + * deletion in the offline sync queue. + * + * @param {{ new(): T }} type - class of the entity to be saved + * @return {Promise} - promise of the element created. + */ + public delete(type: TableStatic | string, keyData: any): + Promise { ... } +} +\end{lstlisting} \begin{it} \subsection{Stato del progetto}