diff --git a/uploader/pom.xml b/uploader/pom.xml index c7f2b9e..1a45969 100644 --- a/uploader/pom.xml +++ b/uploader/pom.xml @@ -96,6 +96,23 @@ junit-jupiter test + + + org.jooq + jooq + 3.19.6 + + + + org.jooq + jooq-meta + 3.19.6 + + + org.jooq + jooq-codegen + 3.19.6 + org.testcontainers mysql diff --git a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/Generator.java b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/Generator.java new file mode 100644 index 0000000..2e1fb87 --- /dev/null +++ b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/Generator.java @@ -0,0 +1,17 @@ +package edu.harvard.dbmi.avillach.dataupload.codegen; + +import org.jooq.Configuration; +import org.jooq.codegen.GenerationTool; + +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class Generator { + public static void main(String[] args) throws Exception { + URI uri = Generator.class.getClassLoader().getResource("jooq.xml").toURI(); + String s = Files.readString(Paths.get(uri)); + GenerationTool.generate(s); + } +} diff --git a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/DefaultCatalog.java b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/DefaultCatalog.java new file mode 100644 index 0000000..51b8bc8 --- /dev/null +++ b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/DefaultCatalog.java @@ -0,0 +1,54 @@ +/* + * This file is generated by jOOQ. + */ +package edu.harvard.dbmi.avillach.dataupload.codegen.generated; + + +import java.util.Arrays; +import java.util.List; + +import org.jooq.Constants; +import org.jooq.Schema; +import org.jooq.impl.CatalogImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" }) +public class DefaultCatalog extends CatalogImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of DEFAULT_CATALOG + */ + public static final DefaultCatalog DEFAULT_CATALOG = new DefaultCatalog(); + + /** + * The schema uploader. + */ + public final Uploader UPLOADER = Uploader.UPLOADER; + + /** + * No further instances allowed + */ + private DefaultCatalog() { + super(""); + } + + @Override + public final List getSchemas() { + return Arrays.asList( + Uploader.UPLOADER + ); + } + + /** + * A reference to the 3.19 minor release of the code generator. If this + * doesn't compile, it's because the runtime library uses an older minor + * release, namely: 3.19. You can turn off the generation of this reference + * by specifying /configuration/generator/generate/jooqVersionReference + */ + private static final String REQUIRE_RUNTIME_JOOQ_VERSION = Constants.VERSION_3_19; +} diff --git a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/Keys.java b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/Keys.java new file mode 100644 index 0000000..658cf30 --- /dev/null +++ b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/Keys.java @@ -0,0 +1,28 @@ +/* + * This file is generated by jOOQ. + */ +package edu.harvard.dbmi.avillach.dataupload.codegen.generated; + + +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.tables.QueryStatus; +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.tables.records.QueryStatusRecord; + +import org.jooq.TableField; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.Internal; + + +/** + * A class modelling foreign key relationships and constraints of tables in + * uploader. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" }) +public class Keys { + + // ------------------------------------------------------------------------- + // UNIQUE and PRIMARY KEY definitions + // ------------------------------------------------------------------------- + + public static final UniqueKey KEY_QUERY_STATUS_PRIMARY = Internal.createUniqueKey(QueryStatus.QUERY_STATUS, DSL.name("KEY_query_status_PRIMARY"), new TableField[] { QueryStatus.QUERY_STATUS.QUERY }, true); +} diff --git a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/Tables.java b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/Tables.java new file mode 100644 index 0000000..d8c42c6 --- /dev/null +++ b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/Tables.java @@ -0,0 +1,20 @@ +/* + * This file is generated by jOOQ. + */ +package edu.harvard.dbmi.avillach.dataupload.codegen.generated; + + +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.tables.QueryStatus; + + +/** + * Convenience access to all tables in uploader. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" }) +public class Tables { + + /** + * The table uploader.query_status. + */ + public static final QueryStatus QUERY_STATUS = QueryStatus.QUERY_STATUS; +} diff --git a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/Uploader.java b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/Uploader.java new file mode 100644 index 0000000..f2b1f41 --- /dev/null +++ b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/Uploader.java @@ -0,0 +1,54 @@ +/* + * This file is generated by jOOQ. + */ +package edu.harvard.dbmi.avillach.dataupload.codegen.generated; + + +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.tables.QueryStatus; + +import java.util.Arrays; +import java.util.List; + +import org.jooq.Catalog; +import org.jooq.Table; +import org.jooq.impl.SchemaImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" }) +public class Uploader extends SchemaImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of uploader + */ + public static final Uploader UPLOADER = new Uploader(); + + /** + * The table uploader.query_status. + */ + public final QueryStatus QUERY_STATUS = QueryStatus.QUERY_STATUS; + + /** + * No further instances allowed + */ + private Uploader() { + super("test", null); + } + + + @Override + public Catalog getCatalog() { + return DefaultCatalog.DEFAULT_CATALOG; + } + + @Override + public final List> getTables() { + return Arrays.asList( + QueryStatus.QUERY_STATUS + ); + } +} diff --git a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/tables/QueryStatus.java b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/tables/QueryStatus.java new file mode 100644 index 0000000..4ad4230 --- /dev/null +++ b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/tables/QueryStatus.java @@ -0,0 +1,239 @@ +/* + * This file is generated by jOOQ. + */ +package edu.harvard.dbmi.avillach.dataupload.codegen.generated.tables; + + +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.tables.records.QueryStatusRecord; +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.Keys; +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.Uploader; + +import java.time.LocalDateTime; +import java.util.Collection; + +import org.jooq.Condition; +import org.jooq.Field; +import org.jooq.Name; +import org.jooq.PlainSQL; +import org.jooq.QueryPart; +import org.jooq.SQL; +import org.jooq.Schema; +import org.jooq.Select; +import org.jooq.Stringly; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" }) +public class QueryStatus extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of uploader.query_status + */ + public static final QueryStatus QUERY_STATUS = new QueryStatus(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return QueryStatusRecord.class; + } + + /** + * The column uploader.query_status.QUERY. + */ + public final TableField QUERY = createField(DSL.name("QUERY"), SQLDataType.BINARY(16).nullable(false), this, ""); + + /** + * The column uploader.query_status.GENOMIC_STATUS. + */ + public final TableField GENOMIC_STATUS = createField(DSL.name("GENOMIC_STATUS"), SQLDataType.VARCHAR(64).nullable(false).defaultValue(DSL.inline("Unsent", SQLDataType.VARCHAR)), this, ""); + + /** + * The column uploader.query_status.PHENOTYPIC_STATUS. + */ + public final TableField PHENOTYPIC_STATUS = createField(DSL.name("PHENOTYPIC_STATUS"), SQLDataType.VARCHAR(64).nullable(false).defaultValue(DSL.inline("Unsent", SQLDataType.VARCHAR)), this, ""); + + /** + * The column uploader.query_status.APPROVED. + */ + public final TableField APPROVED = createField(DSL.name("APPROVED"), SQLDataType.LOCALDATETIME(0), this, ""); + + /** + * The column uploader.query_status.SITE. + */ + public final TableField SITE = createField(DSL.name("SITE"), SQLDataType.VARCHAR(64).nullable(false).defaultValue(DSL.inline("", SQLDataType.VARCHAR)), this, ""); + + private QueryStatus(Name alias, Table aliased) { + this(alias, aliased, (Field[]) null, null); + } + + private QueryStatus(Name alias, Table aliased, Field[] parameters, Condition where) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table(), where); + } + + /** + * Create an aliased uploader.query_status table reference + */ + public QueryStatus(String alias) { + this(DSL.name(alias), QUERY_STATUS); + } + + /** + * Create an aliased uploader.query_status table reference + */ + public QueryStatus(Name alias) { + this(alias, QUERY_STATUS); + } + + /** + * Create a uploader.query_status table reference + */ + public QueryStatus() { + this(DSL.name("query_status"), null); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Uploader.UPLOADER; + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_QUERY_STATUS_PRIMARY; + } + + @Override + public QueryStatus as(String alias) { + return new QueryStatus(DSL.name(alias), this); + } + + @Override + public QueryStatus as(Name alias) { + return new QueryStatus(alias, this); + } + + @Override + public QueryStatus as(Table alias) { + return new QueryStatus(alias.getQualifiedName(), this); + } + + /** + * Rename this table + */ + @Override + public QueryStatus rename(String name) { + return new QueryStatus(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public QueryStatus rename(Name name) { + return new QueryStatus(name, null); + } + + /** + * Rename this table + */ + @Override + public QueryStatus rename(Table name) { + return new QueryStatus(name.getQualifiedName(), null); + } + + /** + * Create an inline derived table from this table + */ + @Override + public QueryStatus where(Condition condition) { + return new QueryStatus(getQualifiedName(), aliased() ? this : null, null, condition); + } + + /** + * Create an inline derived table from this table + */ + @Override + public QueryStatus where(Collection conditions) { + return where(DSL.and(conditions)); + } + + /** + * Create an inline derived table from this table + */ + @Override + public QueryStatus where(Condition... conditions) { + return where(DSL.and(conditions)); + } + + /** + * Create an inline derived table from this table + */ + @Override + public QueryStatus where(Field condition) { + return where(DSL.condition(condition)); + } + + /** + * Create an inline derived table from this table + */ + @Override + @PlainSQL + public QueryStatus where(SQL condition) { + return where(DSL.condition(condition)); + } + + /** + * Create an inline derived table from this table + */ + @Override + @PlainSQL + public QueryStatus where(@Stringly.SQL String condition) { + return where(DSL.condition(condition)); + } + + /** + * Create an inline derived table from this table + */ + @Override + @PlainSQL + public QueryStatus where(@Stringly.SQL String condition, Object... binds) { + return where(DSL.condition(condition, binds)); + } + + /** + * Create an inline derived table from this table + */ + @Override + @PlainSQL + public QueryStatus where(@Stringly.SQL String condition, QueryPart... parts) { + return where(DSL.condition(condition, parts)); + } + + /** + * Create an inline derived table from this table + */ + @Override + public QueryStatus whereExists(Select select) { + return where(DSL.exists(select)); + } + + /** + * Create an inline derived table from this table + */ + @Override + public QueryStatus whereNotExists(Select select) { + return where(DSL.notExists(select)); + } +} diff --git a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/tables/records/QueryStatusRecord.java b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/tables/records/QueryStatusRecord.java new file mode 100644 index 0000000..8769cb5 --- /dev/null +++ b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated/tables/records/QueryStatusRecord.java @@ -0,0 +1,126 @@ +/* + * This file is generated by jOOQ. + */ +package edu.harvard.dbmi.avillach.dataupload.codegen.generated.tables.records; + + +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.tables.QueryStatus; + +import java.time.LocalDateTime; + +import org.jooq.Record1; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" }) +public class QueryStatusRecord extends UpdatableRecordImpl { + + private static final long serialVersionUID = 1L; + + /** + * Setter for uploader.query_status.QUERY. + */ + public void setQuery(byte[] value) { + set(0, value); + } + + /** + * Getter for uploader.query_status.QUERY. + */ + public byte[] getQuery() { + return (byte[]) get(0); + } + + /** + * Setter for uploader.query_status.GENOMIC_STATUS. + */ + public void setGenomicStatus(String value) { + set(1, value); + } + + /** + * Getter for uploader.query_status.GENOMIC_STATUS. + */ + public String getGenomicStatus() { + return (String) get(1); + } + + /** + * Setter for uploader.query_status.PHENOTYPIC_STATUS. + */ + public void setPhenotypicStatus(String value) { + set(2, value); + } + + /** + * Getter for uploader.query_status.PHENOTYPIC_STATUS. + */ + public String getPhenotypicStatus() { + return (String) get(2); + } + + /** + * Setter for uploader.query_status.APPROVED. + */ + public void setApproved(LocalDateTime value) { + set(3, value); + } + + /** + * Getter for uploader.query_status.APPROVED. + */ + public LocalDateTime getApproved() { + return (LocalDateTime) get(3); + } + + /** + * Setter for uploader.query_status.SITE. + */ + public void setSite(String value) { + set(4, value); + } + + /** + * Getter for uploader.query_status.SITE. + */ + public String getSite() { + return (String) get(4); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached QueryStatusRecord + */ + public QueryStatusRecord() { + super(QueryStatus.QUERY_STATUS); + } + + /** + * Create a detached, initialised QueryStatusRecord + */ + public QueryStatusRecord(byte[] query, String genomicStatus, String phenotypicStatus, LocalDateTime approved, String site) { + super(QueryStatus.QUERY_STATUS); + + setQuery(query); + setGenomicStatus(genomicStatus); + setPhenotypicStatus(phenotypicStatus); + setApproved(approved); + setSite(site); + resetChangedOnNotNull(); + } +} diff --git a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/status/DataUploadStatusMapper.java b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/status/DataUploadStatusMapper.java new file mode 100644 index 0000000..94160d9 --- /dev/null +++ b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/status/DataUploadStatusMapper.java @@ -0,0 +1,17 @@ +package edu.harvard.dbmi.avillach.dataupload.status; + +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.tables.records.QueryStatusRecord; +import org.springframework.stereotype.Component; + +@Component +public class DataUploadStatusMapper { + public DataUploadStatuses map(QueryStatusRecord r, String queryUUID) { + return new DataUploadStatuses( + UploadStatus.fromString(r.getGenomicStatus()), + UploadStatus.fromString(r.getPhenotypicStatus()), + queryUUID, + r.getApproved() == null ? null : r.getApproved().toLocalDate(), + r.getSite() + ); + } +} diff --git a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/status/DataUploadStatusesMapper.java b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/status/DataUploadStatusesMapper.java deleted file mode 100644 index 4e9f9bb..0000000 --- a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/status/DataUploadStatusesMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package edu.harvard.dbmi.avillach.dataupload.status; - -import org.springframework.jdbc.core.RowMapper; -import org.springframework.stereotype.Component; - -import java.sql.Date; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.UUID; - -@Component -public class DataUploadStatusesMapper implements RowMapper { - @Override - public DataUploadStatuses mapRow(ResultSet rs, int rowNum) throws SQLException { - UploadStatus genomicStatus = UploadStatus.fromString(rs.getString("GENOMIC_STATUS")); - UploadStatus phenotypicStatus = UploadStatus.fromString(rs.getString("PHENOTYPIC_STATUS")); - String query = fromDashlessString(rs.getString("QUERY")).toString(); - Date approved = rs.getDate("APPROVED"); - String site = rs.getString("SITE"); - return new DataUploadStatuses( - genomicStatus, phenotypicStatus, query, approved == null ? null : approved.toLocalDate(), site - ); - } - - private UUID fromDashlessString(String uuid) { - String dashed = uuid.replaceFirst( - "(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", - "$1-$2-$3-$4-$5" - ); - return UUID.fromString(dashed); - } -} diff --git a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/status/StatusRepository.java b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/status/StatusRepository.java index 48422e4..fddcbb4 100644 --- a/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/status/StatusRepository.java +++ b/uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/status/StatusRepository.java @@ -1,11 +1,20 @@ package edu.harvard.dbmi.avillach.dataupload.status; +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.Tables; +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.tables.QueryStatus; +import edu.harvard.dbmi.avillach.dataupload.codegen.generated.tables.records.QueryStatusRecord; +import org.jooq.DSLContext; +import org.jooq.SQL; +import org.jooq.Table; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Repository; +import java.nio.ByteBuffer; import java.time.LocalDate; import java.util.Optional; +import java.util.UUID; +import java.util.function.Function; @Repository public class StatusRepository { @@ -13,59 +22,68 @@ public class StatusRepository { private JdbcTemplate template; @Autowired - private DataUploadStatusesMapper statusesMapper; + private DataUploadStatusMapper mapper; + + @Autowired + DSLContext dslContext; public Optional getQueryStatus(String queryId) { - String sql = """ - SELECT - GENOMIC_STATUS, PHENOTYPIC_STATUS, hex(QUERY) as QUERY, APPROVED, SITE - FROM - query_status - WHERE - QUERY = unhex(?) - """; - return template.query(sql, statusesMapper, queryId.replace("-", "")) - .stream() - .findFirst(); + UUID uuid = UUID.fromString(queryId); + QueryStatusRecord record = dslContext + .selectFrom(Tables.QUERY_STATUS) + .where(QueryStatus.QUERY_STATUS.QUERY.eq(asBytes(uuid))) + .fetchOne(); + return Optional.ofNullable(record).map(r -> mapper.map(r, queryId)); } public void setGenomicStatus(String queryId, UploadStatus status) { - String sql = """ - INSERT INTO query_status - (query, genomic_status) - VALUES (unhex(?), ?) - ON DUPLICATE KEY UPDATE genomic_status=? - """; - template.update(sql, queryId.replace("-", ""), status.toString(), status.toString()); + UUID uuid = UUID.fromString(queryId); + dslContext + .insertInto(Tables.QUERY_STATUS) + .columns(QueryStatus.QUERY_STATUS.QUERY, QueryStatus.QUERY_STATUS.GENOMIC_STATUS) + .values(asBytes(uuid), status.name()) + .onDuplicateKeyUpdate() + .set(QueryStatus.QUERY_STATUS.GENOMIC_STATUS, status.name()) + .execute(); } public void setPhenotypicStatus(String queryId, UploadStatus status) { - String sql = """ - INSERT INTO query_status - (query, phenotypic_status) - VALUES (unhex(?), ?) - ON DUPLICATE KEY UPDATE phenotypic_status=? - """; - template.update(sql, queryId.replace("-", ""), status.toString(), status.toString()); + UUID uuid = UUID.fromString(queryId); + dslContext + .insertInto(Tables.QUERY_STATUS) + .columns(QueryStatus.QUERY_STATUS.QUERY, QueryStatus.QUERY_STATUS.PHENOTYPIC_STATUS) + .values(asBytes(uuid), status.name()) + .onDuplicateKeyUpdate() + .set(QueryStatus.QUERY_STATUS.PHENOTYPIC_STATUS, status.name()) + .execute(); } public void setApproved(String queryId, LocalDate approvalDate) { - String sql = """ - INSERT INTO query_status - (QUERY, APPROVED) - VALUES (unhex(?), ?) - ON DUPLICATE KEY UPDATE APPROVED=? - """; - template.update(sql, queryId.replace("-", ""), approvalDate, approvalDate); + UUID uuid = UUID.fromString(queryId); + dslContext + .insertInto(Tables.QUERY_STATUS) + .columns(QueryStatus.QUERY_STATUS.QUERY, QueryStatus.QUERY_STATUS.APPROVED) + .values(asBytes(uuid), approvalDate.atStartOfDay()) + .onDuplicateKeyUpdate() + .set(QueryStatus.QUERY_STATUS.APPROVED, approvalDate.atStartOfDay()) + .execute(); } public void setSite(String picSureId, String site) { - String sql = """ - INSERT INTO query_status - (QUERY, SITE) - VALUES (unhex(?), ?) - ON DUPLICATE KEY UPDATE SITE=? - """; - template.update(sql, picSureId.replace("-", ""), site, site); + UUID uuid = UUID.fromString(picSureId); + dslContext + .insertInto(Tables.QUERY_STATUS) + .columns(QueryStatus.QUERY_STATUS.QUERY, QueryStatus.QUERY_STATUS.SITE) + .values(asBytes(uuid), site) + .onDuplicateKeyUpdate() + .set(QueryStatus.QUERY_STATUS.SITE, site) + .execute(); + } + + public static byte[] asBytes(UUID uuid) { + ByteBuffer bb = ByteBuffer.allocate(16); + bb.putLong(uuid.getMostSignificantBits()); + bb.putLong(uuid.getLeastSignificantBits()); + return bb.array(); } } diff --git a/uploader/src/main/resources/jooq.xml b/uploader/src/main/resources/jooq.xml new file mode 100644 index 0000000..bc612cb --- /dev/null +++ b/uploader/src/main/resources/jooq.xml @@ -0,0 +1,46 @@ + + + + com.mysql.jdbc.Driver + jdbc:mysql://localhost:3306/uploader + root + foo + + + + userroot + passwordfoo + + + + + + org.jooq.meta.mysql.MySQLDatabase + .* + + UNUSED_TABLE # This table (unqualified name) should not be generated + | PREFIX_.* # Objects with a given prefix should not be generated + | SECRET_SCHEMA\.SECRET_TABLE # This table (qualified name) should not be generated + | SECRET_ROUTINE # This routine (unqualified name) ... + + + + uploader + + + + + + + edu.harvard.dbmi.avillach.dataupload.generated + + + src/main/java/edu/harvard/dbmi/avillach/dataupload/codegen/generated + + + \ No newline at end of file diff --git a/uploader/src/test/java/edu/harvard/dbmi/avillach/dataupload/status/StatusRepositoryTest.java b/uploader/src/test/java/edu/harvard/dbmi/avillach/dataupload/status/StatusRepositoryTest.java index b1f0392..37ba1fb 100644 --- a/uploader/src/test/java/edu/harvard/dbmi/avillach/dataupload/status/StatusRepositoryTest.java +++ b/uploader/src/test/java/edu/harvard/dbmi/avillach/dataupload/status/StatusRepositoryTest.java @@ -23,7 +23,7 @@ class StatusRepositoryTest { @Container static final MySQLContainer databaseContainer = - new MySQLContainer<>("mysql:8.0").withReuse(true); + new MySQLContainer<>("mysql:8.0.31").withReuse(true); @DynamicPropertySource static void mySQLProperties(DynamicPropertyRegistry registry) {