Skip to content
Snippets Groups Projects
Verified Commit 7274e862 authored by Martin Weise's avatar Martin Weise
Browse files

Refactored enums to lowercase, refactored adv. search

parent 90c8101b
No related branches found
No related tags found
4 merge requests!231CI: Remove build for log-service,!228Better error message handling in the frontend,!223Release of version 1.4.0,!215Resolve "Fix the unit independent search"
Showing
with 900 additions and 607 deletions
......@@ -151,7 +151,7 @@
cName VARCHAR(100),
internal_name VARCHAR(100) NOT NULL,
alias VARCHAR(100),
Datatype ENUM ('CHAR','VARCHAR','BINARY','VARBINARY','TINYBLOB','TINYTEXT','TEXT','BLOB','MEDIUMTEXT','MEDIUMBLOB','LONGTEXT','LONGBLOB','ENUM','SET','BIT','TINYINT','BOOL','SMALLINT','MEDIUMINT','INT','BIGINT','FLOAT','DOUBLE','DECIMAL','DATE','DATETIME','TIMESTAMP','TIME','YEAR'),
Datatype ENUM ('char','varchar','binary','varbinary','tinyblob','tinytext','text','blob','mediumtext','mediumblob','longtext','longblob','enum','set','bit','tinyint','bool','smallint','mediumint','int','bigint','float','double','decimal','date','datetime','timestamp','time','year'),
length INT NULL,
ordinal_position INTEGER NOT NULL,
is_primary_key BOOLEAN NOT NULL,
......@@ -340,7 +340,7 @@
CREATE TABLE IF NOT EXISTS `mdb_banner_messages`
(
id bigint NOT NULL AUTO_INCREMENT,
type ENUM ('ERROR', 'WARNING', 'INFO') NOT NULL default 'INFO',
type ENUM ('error', 'warning', 'info') NOT NULL default 'info',
message TEXT NOT NULL,
link TEXT NULL,
link_text VARCHAR(255) NULL,
......@@ -382,11 +382,11 @@
vid bigint,
publisher VARCHAR(255) NOT NULL,
language VARCHAR(2),
visibility ENUM ('SELF', 'EVERYONE') NOT NULL default 'EVERYONE',
visibility ENUM ('self', 'everyone') NOT NULL default 'everyone',
publication_year INTEGER NOT NULL,
publication_month INTEGER,
publication_day INTEGER,
identifier_type ENUM ('DATABASE', 'SUBSET', 'VIEW') NOT NULL,
identifier_type ENUM ('database', 'subset', 'view') NOT NULL,
query TEXT,
query_normalized TEXT,
query_hash VARCHAR(255),
......@@ -417,7 +417,7 @@
id bigint NOT NULL AUTO_INCREMENT,
pid bigint NOT NULL,
title text NOT NULL,
title_type ENUM ('ALTERNATIVE_TITLE', 'SUBTITLE', 'TRANSLATED_TITLE', 'OTHER'),
title_type ENUM ('alternative_title', 'subtitle', 'translated_title', 'other'),
language VARCHAR(2),
PRIMARY KEY (id),
FOREIGN KEY (pid) REFERENCES mdb_identifiers (id)
......@@ -429,7 +429,7 @@
pid bigint NOT NULL,
funder_name VARCHAR(255) NOT NULL,
funder_identifier TEXT,
funder_identifier_type ENUM ('CROSSREF_FUNDER_ID', 'GRID', 'ISNI', 'ROR', 'OTHER'),
funder_identifier_type ENUM ('crossref_funder_id', 'grid', 'isni', 'ror', 'other'),
scheme_uri text,
award_number VARCHAR(255),
award_title text,
......@@ -443,7 +443,7 @@
id bigint NOT NULL AUTO_INCREMENT,
pid bigint NOT NULL,
description text NOT NULL,
description_type ENUM ('ABSTRACT', 'METHODS', 'SERIES_INFORMATION', 'TABLE_OF_CONTENTS', 'TECHNICAL_INFO', 'OTHER'),
description_type ENUM ('abstract', 'methods', 'series_information', 'table_of_contents', 'technical_info', 'other'),
language VARCHAR(2),
PRIMARY KEY (id),
FOREIGN KEY (pid) REFERENCES mdb_identifiers (id)
......@@ -468,13 +468,13 @@
given_names text,
family_name text,
creator_name VARCHAR(255) NOT NULL,
name_type ENUM ('PERSONAL', 'ORGANIZATIONAL') default 'PERSONAL',
name_type ENUM ('personal', 'organizational') default 'personal',
name_identifier text,
name_identifier_scheme ENUM ('ROR', 'GRID', 'ISNI', 'ORCID'),
name_identifier_scheme ENUM ('ror', 'grid', 'isni', 'orcid'),
name_identifier_scheme_uri text,
affiliation VARCHAR(255),
affiliation_identifier text,
affiliation_identifier_scheme ENUM ('ROR', 'GRID', 'ISNI'),
affiliation_identifier_scheme ENUM ('ror', 'grid', 'isni'),
affiliation_identifier_scheme_uri text,
PRIMARY KEY (id),
FOREIGN KEY (pid) REFERENCES mdb_identifiers (id)
......@@ -515,7 +515,7 @@
(
user_id character varying(36) NOT NULL,
database_id bigint REFERENCES mdb_databases (id),
access_type ENUM ('READ', 'WRITE_OWN', 'WRITE_ALL') NOT NULL,
access_type ENUM ('read', 'write_own', 'write_all') NOT NULL,
created timestamp NOT NULL DEFAULT NOW(),
PRIMARY KEY (user_id, database_id),
FOREIGN KEY (user_id) REFERENCES mdb_users (id)
......
package at.tuwien.converters;
import at.tuwien.entities.database.AccessType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class AccessTypeConverter implements AttributeConverter<AccessType, String> {
@Override
public String convertToDatabaseColumn(AccessType accessType) {
return accessType.name()
.toLowerCase();
}
@Override
public AccessType convertToEntityAttribute(String accessType) {
return AccessType.valueOf(accessType.toUpperCase());
}
}
package at.tuwien.converters;
import at.tuwien.entities.identifier.AffiliationIdentifierSchemeType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class IdentifierAffiliationIdentifierSchemeTypeConverter implements AttributeConverter<AffiliationIdentifierSchemeType, String> {
@Override
public String convertToDatabaseColumn(AffiliationIdentifierSchemeType columnType) {
return columnType.name()
.toLowerCase();
}
@Override
public AffiliationIdentifierSchemeType convertToEntityAttribute(String columnType) {
return AffiliationIdentifierSchemeType.valueOf(columnType.toUpperCase());
}
}
package at.tuwien.converters;
import at.tuwien.entities.identifier.DescriptionType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class IdentifierDescriptionTypeConverter implements AttributeConverter<DescriptionType, String> {
@Override
public String convertToDatabaseColumn(DescriptionType columnType) {
return columnType.name()
.toLowerCase();
}
@Override
public DescriptionType convertToEntityAttribute(String columnType) {
return DescriptionType.valueOf(columnType.toUpperCase());
}
}
package at.tuwien.converters;
import at.tuwien.entities.identifier.IdentifierFunderType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class IdentifierFunderTypeConverter implements AttributeConverter<IdentifierFunderType, String> {
@Override
public String convertToDatabaseColumn(IdentifierFunderType columnType) {
return columnType.name()
.toLowerCase();
}
@Override
public IdentifierFunderType convertToEntityAttribute(String columnType) {
return IdentifierFunderType.valueOf(columnType.toUpperCase());
}
}
package at.tuwien.converters;
import at.tuwien.entities.identifier.IdentifierType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class IdentifierIdentifierTypeConverter implements AttributeConverter<IdentifierType, String> {
@Override
public String convertToDatabaseColumn(IdentifierType columnType) {
return columnType.name()
.toLowerCase();
}
@Override
public IdentifierType convertToEntityAttribute(String columnType) {
return IdentifierType.valueOf(columnType.toUpperCase());
}
}
package at.tuwien.converters;
import at.tuwien.entities.identifier.NameIdentifierSchemeType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class IdentifierNameIdentifierSchemeTypeConverter implements AttributeConverter<NameIdentifierSchemeType, String> {
@Override
public String convertToDatabaseColumn(NameIdentifierSchemeType columnType) {
return columnType.name()
.toLowerCase();
}
@Override
public NameIdentifierSchemeType convertToEntityAttribute(String columnType) {
return NameIdentifierSchemeType.valueOf(columnType.toUpperCase());
}
}
package at.tuwien.converters;
import at.tuwien.entities.identifier.NameType;
import at.tuwien.entities.identifier.RelatedType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class IdentifierNameTypeConverter implements AttributeConverter<NameType, String> {
@Override
public String convertToDatabaseColumn(NameType columnType) {
return columnType.name()
.toLowerCase();
}
@Override
public NameType convertToEntityAttribute(String columnType) {
return NameType.valueOf(columnType.toUpperCase());
}
}
package at.tuwien.converters;
import at.tuwien.entities.identifier.RelatedType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class IdentifierRelatedTypeConverter implements AttributeConverter<RelatedType, String> {
@Override
public String convertToDatabaseColumn(RelatedType columnType) {
return columnType.name()
.toLowerCase();
}
@Override
public RelatedType convertToEntityAttribute(String columnType) {
return RelatedType.valueOf(columnType.toUpperCase());
}
}
package at.tuwien.converters;
import at.tuwien.entities.identifier.VisibilityType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class IdentifierVisibilityTypeConverter implements AttributeConverter<VisibilityType, String> {
@Override
public String convertToDatabaseColumn(VisibilityType columnType) {
return columnType.name()
.toLowerCase();
}
@Override
public VisibilityType convertToEntityAttribute(String columnType) {
return VisibilityType.valueOf(columnType.toUpperCase());
}
}
package at.tuwien.converters;
import at.tuwien.entities.database.LanguageType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class LanguageTypeConverter implements AttributeConverter<LanguageType, String> {
@Override
public String convertToDatabaseColumn(LanguageType columnType) {
return columnType.name()
.toLowerCase();
}
@Override
public LanguageType convertToEntityAttribute(String columnType) {
return LanguageType.valueOf(columnType.toUpperCase());
}
}
package at.tuwien.converters;
import at.tuwien.entities.database.table.columns.TableColumnType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter
public class TableColumnTypeConverter implements AttributeConverter<TableColumnType, String> {
@Override
public String convertToDatabaseColumn(TableColumnType columnType) {
return columnType.name()
.toLowerCase();
}
@Override
public TableColumnType convertToEntityAttribute(String columnType) {
return TableColumnType.valueOf(columnType.toUpperCase());
}
}
......@@ -4,9 +4,22 @@ import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
public enum AccessType {
READ,
WRITE_OWN,
WRITE_ALL;
READ("read"),
WRITE_OWN("write_own"),
WRITE_ALL("write_all");
private String name;
AccessType(String name) {
this.name = name;
}
@Override
public String toString() {
return this.name;
}
}
......@@ -107,7 +107,7 @@ public class Database implements Serializable {
@OneToOne(fetch = FetchType.LAZY)
@JoinColumnsOrFormulas({
@JoinColumnOrFormula(column = @JoinColumn(name = "id", referencedColumnName = "dbid", insertable = false, updatable = false)),
@JoinColumnOrFormula(formula = @JoinFormula(referencedColumnName = "identifier_type", value = "'DATABASE'"))
@JoinColumnOrFormula(formula = @JoinFormula(referencedColumnName = "identifier_type", value = "'database'"))
})
private Identifier identifier;
......
package at.tuwien.entities.database;
import at.tuwien.converters.AccessTypeConverter;
import at.tuwien.entities.user.User;
import lombok.*;
import org.hibernate.annotations.JdbcTypeCode;
......@@ -50,8 +51,8 @@ public class DatabaseAccess {
})
private Database database;
@Column(nullable = false, name = "access_type", columnDefinition = "enum('READ', 'WRITE_OWN', 'WRITE_ALL')")
@Enumerated(EnumType.STRING)
@Column(nullable = false, name = "access_type", columnDefinition = "enum('read', 'write_own', 'write_all')")
@Convert(converter = AccessTypeConverter.class)
private AccessType type;
@Column(nullable = false, updatable = false, columnDefinition = "TIMESTAMP")
......
......@@ -85,7 +85,7 @@ public class View {
@OneToOne(fetch = FetchType.LAZY)
@JoinColumnsOrFormulas({
@JoinColumnOrFormula(column = @JoinColumn(name = "id", referencedColumnName = "vid", insertable = false, updatable = false)),
@JoinColumnOrFormula(formula = @JoinFormula(referencedColumnName = "identifier_type", value = "'VIEW'"))
@JoinColumnOrFormula(formula = @JoinFormula(referencedColumnName = "identifier_type", value = "'view'"))
})
private Identifier identifier;
......
package at.tuwien.entities.database.table.columns;
import at.tuwien.converters.TableColumnTypeConverter;
import at.tuwien.entities.container.image.ContainerImageDate;
import at.tuwien.entities.database.View;
import at.tuwien.entities.database.table.Table;
......@@ -10,6 +11,7 @@ import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import jakarta.persistence.*;
import java.time.Instant;
import java.util.List;
......@@ -69,8 +71,8 @@ public class TableColumn implements Comparable<TableColumn> {
@Column
private String alias;
@Column(name = "datatype", nullable = false)
@Enumerated(EnumType.STRING)
@Column(name = "datatype", nullable = false, columnDefinition = "ENUM('char','varchar','binary','varbinary','tinyblob','tinytext','text','blob','mediumtext','mediumblob','longtext','longblob','enum','set','bit','tinyint','bool','smallint','mediumint','int','bigint','float','double','decimal','date','datetime','timestamp','time','year')")
@Convert(converter = TableColumnTypeConverter.class)
private TableColumnType columnType;
@Column
......
......@@ -4,35 +4,74 @@ import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
public enum TableColumnType {
CHAR,
VARCHAR,
BINARY,
VARBINARY,
TINYBLOB,
TINYTEXT,
TEXT,
BLOB,
MEDIUMTEXT,
MEDIUMBLOB,
LONGTEXT,
LONGBLOB,
ENUM,
SET,
BIT,
TINYINT,
BOOL,
SMALLINT,
MEDIUMINT,
INT,
BIGINT,
FLOAT,
DOUBLE,
DECIMAL,
DATE,
DATETIME,
TIMESTAMP,
TIME,
YEAR;
CHAR("char"),
VARCHAR("varchar"),
BINARY("binary"),
VARBINARY("varbinary"),
TINYBLOB("tinyblob"),
TINYTEXT("tinytext"),
TEXT("text"),
BLOB("blob"),
MEDIUMTEXT("mediumtext"),
MEDIUMBLOB("mediumblob"),
LONGTEXT("longtext"),
LONGBLOB("longblob"),
ENUM("enum"),
SET("set"),
BIT("bit"),
TINYINT("tinyint"),
BOOL("bool"),
SMALLINT("smallint"),
MEDIUMINT("mediumint"),
INT("int"),
BIGINT("bigint"),
FLOAT("float"),
DOUBLE("double"),
DECIMAL("decimal"),
DATE("date"),
DATETIME("datetime"),
TIMESTAMP("timestamp"),
TIME("time"),
YEAR("year");
private String name;
TableColumnType(String name) {
this.name = name;
}
@Override
public String toString() {
return this.name;
}
}
\ No newline at end of file
......@@ -5,7 +5,21 @@ import lombok.Getter;
@Getter
public enum AffiliationIdentifierSchemeType {
ROR,
GRID,
ISNI
ROR("ror"),
GRID("grid"),
ISNI("isni");
private String name;
AffiliationIdentifierSchemeType(String name) {
this.name = name;
}
@Override
public String toString() {
return this.name;
}
}
package at.tuwien.entities.identifier;
import at.tuwien.converters.IdentifierAffiliationIdentifierSchemeTypeConverter;
import at.tuwien.converters.IdentifierNameIdentifierSchemeTypeConverter;
import at.tuwien.converters.IdentifierNameTypeConverter;
import lombok.*;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
......@@ -32,15 +35,15 @@ public class Creator {
@Column(name = "creator_name", nullable = false)
private String creatorName;
@Column(columnDefinition = "enum('PERSONAL', 'ORGANIZATIONAL')")
@Enumerated(EnumType.STRING)
@Column(columnDefinition = "enum('personal', 'organizational')")
@Convert(converter = IdentifierNameTypeConverter.class)
private NameType nameType;
@Column
private String nameIdentifier;
@Column(columnDefinition = "enum('ROR', 'GRID', 'ISNI', 'ORCID')")
@Enumerated(EnumType.STRING)
@Column(columnDefinition = "enum('ror', 'grid', 'isni', 'orcid')")
@Convert(converter = IdentifierNameIdentifierSchemeTypeConverter.class)
private NameIdentifierSchemeType nameIdentifierScheme;
@Column
......@@ -52,8 +55,8 @@ public class Creator {
@Column
private String affiliationIdentifier;
@Column(columnDefinition = "enum('ROR', 'GRID', 'ISNI')")
@Enumerated(EnumType.STRING)
@Column(columnDefinition = "enum('ror', 'grid', 'isni')")
@Convert(converter = IdentifierAffiliationIdentifierSchemeTypeConverter.class)
private AffiliationIdentifierSchemeType affiliationIdentifierScheme;
private String affiliationIdentifierSchemeUri;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment