com.atomizesoftware.spin.data.dao

DataModel

trait DataModel extends AnyRef

Defines a data model to be used by DAO instances

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. DataModel
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. class DataModelException extends Exception

Abstract Value Members

  1. abstract val db: scala.slick.jdbc.JdbcBackend.Database

    A slick Database instance

  2. abstract val dbIdiom: DatabaseIdiom

    Holds the idiom used for building the SQL statements

  3. abstract val tables: List[Table[_]]

    List of all Tables in the database

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. final def childrenTableInfos(tableInfo: TableInfo, include: String, level: Int, previousTableInfos: List[TableInfo]): List[TableInfo]

  6. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def columnsNamesWithReferences(tableInfo: TableInfo): List[String]

    Holds a list of all column names, with the proper placeholder alias ("Container_0_1"), quoted according to the database idiom

    Holds a list of all column names, with the proper placeholder alias ("Container_0_1"), quoted according to the database idiom

    returns

    a list of column names with the right references like such "Container"."Number" or "Container01"."Number"

  8. def columnsTypes(table: Table[_]): List[Class[_]]

    List with all the data types of all columns

  9. def convertValueToDBIdiom(value: Any): String

    Converts a value to string according to the defined database idiom, so it can be used in queries

    Converts a value to string according to the defined database idiom, so it can be used in queries

    value

    any value

  10. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. def findColumn(tableInfos: Seq[TableInfo], columnName: String): Option[(TableInfo, Column)]

    Finds a column in a table and based on a name returning the table and column.

    Finds a column in a table and based on a name returning the table and column.

    tableInfos

    to search the column in

    columnName

    name of the column to search for

    returns

    tuple with the table and column found if any, None otherwise

  14. def fullTextSearch(tables: Seq[TableInfo], expression: String): (String, List[String])

    Composes the full text search string to be used in a SELECT statement when a quick search is performed

    Composes the full text search string to be used in a SELECT statement when a quick search is performed

    tables

    all tables in the query

  15. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  16. def getColumnInTable(table: Table[_], columnName: String): Option[Column]

    Finds the column with the given name.

    Finds the column with the given name. If not found, returns None

    table

    the table where to find the column

    columnName

    the name of the column we want to find

  17. def getInfosAndJoinsForStatement(mainTable: Table[_], include: String): StatementBuilderInfo

    Returns the needed table infos and joins for a select statement.

  18. def getInfosJoinsAndColumnNamesForStatement(mainTable: Table[_], include: String, timeZoneId: Option[String] = None): StatementBuilderInfo

    Returns the needed table infos, joins and column names for a select statement.

    Returns the needed table infos, joins and column names for a select statement.

    returns

    StatementBuilderInfo with the tableInfos, columnNames and join string.

  19. def getJoins(allTableInfos: Seq[TableInfo] = Seq()): String

    Composes the join string to be used in a SELECT statement

    Composes the join string to be used in a SELECT statement

    allTableInfos

    all info of all the tables that will be in the select statement.

    returns

    a string representing the join statements for the select.

  20. def getOrderByForStatement(tableInfos: Seq[TableInfo], idColumn: String, orderByFilter: String = ""): String

    Returns the order by statement whether a filter was included or not.

    Returns the order by statement whether a filter was included or not.

    returns

    a string for the orderByFilter or a default order by string for the idColumn.

  21. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  22. def innerJoin(tableInfos: Seq[TableInfo], joinTable: TableInfo): String

    Build an inner join string to be used when composing SELECT statements.

  23. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  24. def leftJoin(tableInfos: Seq[TableInfo], joinTable: TableInfo): String

    Builds a left join string to be used when composing SELECT statements.

  25. def mkPGobject(typeName: String, value: String): PGobject

  26. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  27. final def notify(): Unit

    Definition Classes
    AnyRef
  28. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  29. def orderBy(tables: Seq[TableInfo], filter: String): String

    Returns a string of the Order By segment to use in the SELECT statement

    Returns a string of the Order By segment to use in the SELECT statement

    tables

    where the column to order by might be

    filter

    column and order to use in the statement

  30. def page(offset: Int, size: Int): String

    Builds a string to apply paging to the SELECT statement

  31. def parameterFor[T](value: T, column: Column, pp: PositionedParameters): Option[Unit]

    Transforms a value in a parameter to be used in an insert or update sql statement.

    Transforms a value in a parameter to be used in an insert or update sql statement.

    In order to convert the values into parameters we need to know the underlying type of the value, in order to go around type erasure we pass the column of the value along with the value to be converted, this way when the value is None we can find out which underlying type None pertains to. This needs to be done because SetParameter sets a type for None values that needs to equal the sql column type.

    value

    of the parameter

    column

    to which pertains the parameter

    pp

    positioned parameters

  32. def parameterFor[T](value: T, pp: PositionedParameters): Option[Unit]

    Transforms a value in a parameter to be used in a sql statement according to its type.

    Transforms a value in a parameter to be used in a sql statement according to its type.

    value

    of the parameter

    pp

    positioned parameters

  33. def parseFilterParams(operator: String, tables: Seq[TableInfo], filter: String): (String, List[Any])

    Transforms a filter string in a partial sql statement string with the parameters to use.

    Transforms a filter string in a partial sql statement string with the parameters to use.

    operator

    used to join the different filtered statements

    tables

    to search in order to get the names present in the filter

    filter

    that contains the filters to apply in the sql statement

    returns

    a partial sql statement and the parameters to apply in it.

  34. def parseSearch(tables: Seq[TableInfo], search: String): (String, List[Any])

    Checks if the search string pertains to an advanced search or a quick search and calls upon parseSearchParams or fullTextSearch respectively

    Checks if the search string pertains to an advanced search or a quick search and calls upon parseSearchParams or fullTextSearch respectively

    returns

    a tuple with the partialSql string and a list of params that apply to it.

  35. def parseSearchInput(expression: String): String

    Takes the search expression from user input and parses it according to the current dbIdiom

    Takes the search expression from user input and parses it according to the current dbIdiom

    Replace multiple spaces by a single one then replace a space by an AND operator

    expression

    the search expression input by the user

  36. def parseSearchParams(operator: String, tables: Seq[TableInfo], search: String): (String, List[Any])

    Transforms a search string in a partial sql statement string with the parameters to use.

    Transforms a search string in a partial sql statement string with the parameters to use.

    This function is only used when performing an advanced search.

    operator

    used to join the different filtered statements

    tables

    to search in order to get the names present in the search string

    search

    string that contains the conditions to apply in the sql statement.

    returns

    a partial sql statement and the parameters to apply in it.

  37. final def parseTables(mainTable: Table[_], include: String, motherTableAlias: String = "", path: String = "", level: Int = 0): List[TableInfo]

    Parses a comma separated string of table names into a list of TableInfo instances.

    Parses a comma separated string of table names into a list of TableInfo instances. Table names are case insensitive.

    In order to parse the table names it searches the main table's reference list and tries to match them with the table names in the include string. The results is then a pair containing the table associated with that reference and the name of the reference.

    Example: for include as "containertype,containerstatus" when mainTable is Container returns List(TableInfo(Table[ContainerType],"ContainerType","Container","_0_1","ContainerType"), TableInfo(Table[ContainerStatus],"ContainerStatus","Container","_0_0","ContainerStatus"))

    Example: for include as "container,container.containerstatus" when mainTable is Movement returns List(TableInfo(Table[Container],"Container","Movement","_0_3","Container"), TableInfo(Table[ContainerStatus],"ContainerStatus","Container_0_3","_13_0","Container.ContainerStatus"))

  38. def pathToReference(table: Table[_])(implicit alias: String): String

    Returns the correct alias to be used when reading the query results.

    Returns the correct alias to be used when reading the query results.

    returns

    a string representing the correct alias to read in query results.

  39. def pathToReferenceWithCode(code: String)(implicit alias: String): String

    Returns the correct alias to be used when reading the query results.

    Returns the correct alias to be used when reading the query results.

    returns

    a string representig the correct alias to read in query results.

  40. def qualifiedColumnsNames(table: Table[_]): List[String]

    Holds a list of all column names, properly quoted for the current dbIdiom value

  41. def qualifiedColumnsNamesWithAlias(tableInfo: TableInfo, tables: Option[Seq[TableInfo]] = None, timeZoneId: Option[String] = None): List[String]

    Holds a list of all column names, quoted and with the SQL alias declaration appended

    Holds a list of all column names, quoted and with the SQL alias declaration appended

    These aliases are used in SELECTS and have the goal to prevent duplicated column names where there are inner joins. Example: for a column named Id in the Container table, the corresponding value in this list is "Container"."Id" AS Container0Id given that 0 is the position of the column.

    Example: for a column named Id in a reference named CurrentContainer, the corresponding values in this list is "CurrentContainer"."Id" AS CurrentContainer10Id.

  42. def qualifiedPkName(table: Table[_]): String

    Holds Table.pk properly quoted for the database idiom and ready to be used in queries

  43. def qualifiedTableName(table: Table[_]): String

    Holds the quoted table name.

    Holds the quoted table name.

    Example: considering a table named Container, this value is "Container" if idiom is PostgreSQL or [Container] if SQLServer

  44. def quote(string: String): String

    Quotes a string according to the defined dbIdiom

    Quotes a string according to the defined dbIdiom

    Example: if string is Spin, this returns [Spin] if dbIdiom is SQLServer and "Spin" if PostgreSQL

    string

    the string to be quoted

  45. def removeSpecialColumnsAndValues(table: Table[_], values: Seq[Any]): ColumnValues

    Removes special columns and values like Primary Key and SyncTimestamp from a table a list of values, returns ColumnValues with a list of columns and values.

    Removes special columns and values like Primary Key and SyncTimestamp from a table a list of values, returns ColumnValues with a list of columns and values.

    table

    the table where to remove the columns.

    values

    the list of values related to the given table.

  46. final def retryOnSQLError[T](error: SQLError, times: Int = 1)(fn: ⇒ T): T

    Executes the thunk (fn) and retries if occurs a SQL error of the type defined in the error parameter

    Executes the thunk (fn) and retries if occurs a SQL error of the type defined in the error parameter

    error

    the error type that causes the retrie

    times

    the number of retries (not the number of runs). Deafault is one retry

    fn

    the function to run and retry, if necessary

    Annotations
    @tailrec()
  47. def seqParam[A](implicit pconv: SetParameter[A]): SetParameter[Seq[A]]

  48. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  49. def tableFor(tableName: String): Option[Table[_]]

    Retrieves the Table instance with the given name.

    Retrieves the Table instance with the given name. If not found, returns None. The name is case insensitive.

  50. def tableFor[T](implicit arg0: ClassTag[T], tag: ClassTag[T]): Table[T]

    Retrieves the Table for the type T

  51. def toNativeValue(table: Table[_], columnName: String, value: String): Option[Any]

    Takes a value in string format and tries to convert it to a quoted string according to the database idiom and column data type

  52. def toString(): String

    Definition Classes
    AnyRef → Any
  53. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  54. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  55. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped