Class DbObjectSchema
java.lang.Object
tech.ailef.dbadmin.external.dbmapping.DbObjectSchema
A class that represents a table/`@Entity` as reconstructed from the
JPA annotations found on its fields.
-
Constructor Summary
ConstructorsConstructorDescriptionDbObjectSchema
(Class<?> klass, DbAdmin dbAdmin) Initializes this schema for the specific `@Entity` class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addError
(MappingError error) void
Adds a field to this schema.buildObject
(Map<String, String> params, Map<String, org.springframework.web.multipart.MultipartFile> files) boolean
findAll()
Returns all the data in this schema, as `DbObject`sReturns the name of the Java class for the underlying `@Entity` this schema corresponds togetComputedColumn
(String name) Returns the method for the given `@ComputedColumn` nameReturns the names of the `@ComputedColumn`s in this schemaReturns the DbAdmin instancegetFieldByJavaName
(String name) Get a field by its Java name, i.e.getFieldByName
(String name) Get a field by its database name, i.e.Returns an unmodifiable list of all the fields in the schemaReturns the list of fields that are `@Filterable`Class<?>
Returns the Java class for the underlying `@Entity` this schema corresponds toReturns the underlying CustomJpaRepositoryReturns the list of ManyToMany fields owned by this class (i.e.Returns the DbField which serves as the primary key for this schemaReturns the list of relationship fieldsgetSortedFields
(boolean readOnly) Returns a sorted list of physical fields (i.e., fields that correspond to a column in the table as opposed to fields that are just present as instance variables, like relationship fields).Returns the inferred table name for this schemaint
hashCode()
boolean
boolean
boolean
void
setJpaRepository
(CustomJpaRepository jpaRepository) Sets the underlying CustomJpaRepositorytoString()
-
Constructor Details
-
DbObjectSchema
Initializes this schema for the specific `@Entity` class. Determines the table name from the `@Table` annotation and also which methods are `@ComputedColumn`s- Parameters:
klass
- the `@Entity` classdbAdmin
- the DbAdmin instance
-
-
Method Details
-
getBasePackage
-
getDbAdmin
Returns the DbAdmin instance- Returns:
- the DbAdmin instance
-
getJavaClass
Returns the Java class for the underlying `@Entity` this schema corresponds to- Returns:
- the Java class for the `@Entity` this schema corresponds to
-
getClassName
Returns the name of the Java class for the underlying `@Entity` this schema corresponds to- Returns:
- the name of the Java class for the `@Entity` this schema corresponds to
-
getFields
Returns an unmodifiable list of all the fields in the schema- Returns:
- an unmodifiable list of all the fields in the schema
-
getErrors
-
getFieldByJavaName
Get a field by its Java name, i.e. the name of the instance variable in the `@Entity` class- Parameters:
name
- name of the instance variable- Returns:
- the DbField if found, null otherwise
-
getFieldByName
Get a field by its database name, i.e. the name of the column corresponding to the field- Parameters:
name
- name of the column- Returns:
- the DbField if found, null otherwise
-
addField
Adds a field to this schema. This is used by the DbAdmin instance during initialization and it's not supposed to be called afterwards- Parameters:
f
- the DbField to add
-
addError
-
getJpaRepository
Returns the underlying CustomJpaRepository- Returns:
-
setJpaRepository
Sets the underlying CustomJpaRepository- Parameters:
jpaRepository
-
-
getTableName
Returns the inferred table name for this schema- Returns:
-
getSortedFields
- Returns:
-
getSortedFields
Returns a sorted list of physical fields (i.e., fields that correspond to a column in the table as opposed to fields that are just present as instance variables, like relationship fields). Sorted alphabetically with priority the primary key, and non nullable fields. If readOnly is true, `@HiddenColumn`s are not returned. If instead readOnly is false, i.e. how it gets called in the create/edit page, hidden columns are included if they are not nullable.- Parameters:
readOnly
- whether we only need to read the fields are create/edit- Returns:
-
getRelationshipFields
Returns the list of relationship fields- Returns:
-
getManyToManyOwnedFields
Returns the list of ManyToMany fields owned by this class (i.e. they do not have "mappedBy")- Returns:
-
getPrimaryKey
Returns the DbField which serves as the primary key for this schema- Returns:
-
getComputedColumnNames
Returns the names of the `@ComputedColumn`s in this schema- Returns:
-
getComputedColumn
Returns the method for the given `@ComputedColumn` name- Parameters:
name
- the name of the `@ComputedColumn`- Returns:
- the corresponding instance method if found, null otherwise
-
getFilterableFields
Returns the list of fields that are `@Filterable`- Returns:
-
isDeleteEnabled
public boolean isDeleteEnabled() -
isEditEnabled
public boolean isEditEnabled() -
isCreateEnabled
public boolean isCreateEnabled() -
findAll
Returns all the data in this schema, as `DbObject`s- Returns:
-
buildObject
-
toString
-
hashCode
public int hashCode() -
equals
-