|
26 | 26 | import org.icij.datashare.text.Tag; |
27 | 27 | import org.icij.datashare.text.nlp.Pipeline; |
28 | 28 | import org.icij.datashare.user.User; |
29 | | -import org.jooq.DSLContext; |
30 | | -import org.jooq.Field; |
31 | | -import org.jooq.InsertOnDuplicateSetMoreStep; |
32 | | -import org.jooq.InsertValuesStep2; |
33 | | -import org.jooq.InsertValuesStep3; |
34 | | -import org.jooq.InsertValuesStep4; |
35 | | -import org.jooq.InsertValuesStep5; |
36 | | -import org.jooq.InsertValuesStep6; |
37 | | -import org.jooq.InsertValuesStep9; |
| 29 | +import org.jooq.*; |
38 | 30 | import org.jooq.Record; |
39 | | -import org.jooq.Record1; |
40 | | -import org.jooq.SQLDialect; |
41 | | -import org.jooq.SelectConditionStep; |
42 | | -import org.jooq.SelectJoinStep; |
43 | | -import org.jooq.SelectOnConditionStep; |
44 | | -import org.jooq.SelectSelectStep; |
45 | | -import org.jooq.SortField; |
46 | | -import org.jooq.UpdateConditionStep; |
47 | | -import org.jooq.UpdateSetMoreStep; |
48 | 31 | import org.jooq.exception.DataAccessException; |
49 | 32 | import org.jooq.impl.DSL; |
50 | 33 | import org.slf4j.LoggerFactory; |
|
89 | 72 | import static org.jooq.impl.DSL.condition; |
90 | 73 | import static org.jooq.impl.DSL.count; |
91 | 74 | import static org.jooq.impl.DSL.countDistinct; |
| 75 | +import static org.jooq.impl.DSL.field; |
92 | 76 | import static org.jooq.impl.DSL.using; |
93 | 77 | import static org.jooq.impl.DSL.value; |
94 | 78 |
|
@@ -534,8 +518,8 @@ public boolean save(Note note) { |
534 | 518 |
|
535 | 519 | @Override |
536 | 520 | public boolean save(Project project) { |
537 | | - LocalDateTime projectCreationDate = project.creationDate == null ? null : LocalDateTime.ofInstant(project.creationDate.toInstant(),ZoneOffset.UTC); |
538 | | - LocalDateTime projectUpdateDate = project.updateDate == null ? null : LocalDateTime.ofInstant(project.updateDate.toInstant(),ZoneOffset.UTC); |
| 521 | + LocalDateTime projectCreationDate = project.creationDate == null ? null : LocalDateTime.ofInstant(project.creationDate.toInstant(), ZoneOffset.UTC); |
| 522 | + LocalDateTime projectUpdateDate = project.updateDate == null ? null : LocalDateTime.ofInstant(project.updateDate.toInstant(), ZoneOffset.UTC); |
539 | 523 | InsertOnDuplicateSetMoreStep<ProjectRecord> innerSet = using(connectionProvider, dialect).insertInto( |
540 | 524 | PROJECT, PROJECT.ID, PROJECT.LABEL, PROJECT.DESCRIPTION, PROJECT.PATH, PROJECT.SOURCE_URL, |
541 | 525 | PROJECT.MAINTAINER_NAME, PROJECT.PUBLISHER_NAME, PROJECT.LOGO_URL, |
@@ -582,6 +566,28 @@ public User getUser(String uid) { |
582 | 566 | return createUserFrom(ctx.selectFrom(USER_INVENTORY).where(USER_INVENTORY.ID.eq(uid)).fetchOne()); |
583 | 567 | } |
584 | 568 |
|
| 569 | + @Override |
| 570 | + public void temporaryFixLiquibaseIds() { |
| 571 | + using(connectionProvider, dialect).transaction(configuration -> { |
| 572 | + DSLContext inner = using(configuration); |
| 573 | + Field<String> id = field("id", String.class); |
| 574 | + Result<? extends Record1<String>> records = inner.select(id).from("databasechangelog").where("filename=?", "liquibase/changelog/changes/043-adds-user-policy-table.yml").fetch(); |
| 575 | + if (records.isNotEmpty()) { |
| 576 | + inner.queries( |
| 577 | + inner.query("UPDATE databasechangelog set id='64' where filename='liquibase/changelog/changes/036-create_task.yml'"), |
| 578 | + inner.query("UPDATE databasechangelog set id='65' where filename='liquibase/changelog/changes/037-adds-task-result-and-error.yml'"), |
| 579 | + inner.query("UPDATE databasechangelog set id='66' where filename='liquibase/changelog/changes/038-adds-uri-column-batch-search.yml'"), |
| 580 | + inner.query("UPDATE databasechangelog set id='67' where filename='liquibase/changelog/changes/039-adds-column-nb-queries-without-results-batch-search.yml'"), |
| 581 | + inner.query("UPDATE databasechangelog set id='68' where filename='liquibase/changelog/changes/040-sqlite-pragma-journal-wal.yml'"), |
| 582 | + inner.query("UPDATE databasechangelog set id='69' where filename='liquibase/changelog/changes/041-adds-column-blur-sensitive-to-note.yml'"), |
| 583 | + inner.query("UPDATE databasechangelog set id='70' where id='42' and filename='liquibase/changelog/changes/042-task-result-batch-search-migration.yml'"), |
| 584 | + inner.query("UPDATE databasechangelog set id='71' where id='43' and filename='liquibase/changelog/changes/042-task-result-batch-search-migration.yml'"), |
| 585 | + inner.query("DELETE FROM databasechangelog where filename='liquibase/changelog/changes/043-adds-user-policy-table.yml'") |
| 586 | + ).executeBatch(); |
| 587 | + } |
| 588 | + }); |
| 589 | + } |
| 590 | + |
585 | 591 | @Override |
586 | 592 | public boolean getHealth() { |
587 | 593 | DSLContext ctx = DSL.using(connectionProvider, dialect); |
@@ -701,7 +707,8 @@ private Document createDocumentFrom(Record result) { |
701 | 707 | DocumentRecord documentRecord = result.into(DOCUMENT); |
702 | 708 | Map<String, Object> metadata; |
703 | 709 | try { |
704 | | - metadata = JsonObjectMapper.readValue(documentRecord.getMetadata(), new TypeReference<>() {}); |
| 710 | + metadata = JsonObjectMapper.readValue(documentRecord.getMetadata(), new TypeReference<>() { |
| 711 | + }); |
705 | 712 | } catch (IOException e) { |
706 | 713 | throw new RuntimeException(e); |
707 | 714 | } |
|
0 commit comments