From c205dc3fa7b6f388df5045f7cad1afcc9e6fd034 Mon Sep 17 00:00:00 2001 From: Markus Date: Fri, 4 Dec 2020 11:00:12 +0100 Subject: [PATCH] Add 2 new commands --- .../catalogue/tools/UpdateReleaseTool.java | 20 ++++++++++++++++--- .../main/java/life/catalogue/WsServer.java | 12 +++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/dao/src/main/java/life/catalogue/tools/UpdateReleaseTool.java b/dao/src/main/java/life/catalogue/tools/UpdateReleaseTool.java index 30b1fb1471..0b7f295838 100644 --- a/dao/src/main/java/life/catalogue/tools/UpdateReleaseTool.java +++ b/dao/src/main/java/life/catalogue/tools/UpdateReleaseTool.java @@ -2,7 +2,10 @@ import com.zaxxer.hikari.HikariDataSource; import life.catalogue.api.model.Dataset; +import life.catalogue.api.model.DatasetSettings; import life.catalogue.api.vocab.DatasetOrigin; +import life.catalogue.api.vocab.Setting; +import life.catalogue.common.text.CitationUtils; import life.catalogue.dao.*; import life.catalogue.db.MybatisFactory; import life.catalogue.db.PgConfig; @@ -10,7 +13,10 @@ import life.catalogue.db.mapper.ProjectSourceMapper; import life.catalogue.es.NameUsageIndexService; import life.catalogue.matching.NameIndexFactory; -import life.catalogue.matching.decision.*; +import life.catalogue.matching.decision.EstimateRematcher; +import life.catalogue.matching.decision.RematcherBase; +import life.catalogue.matching.decision.SectorRematchRequest; +import life.catalogue.matching.decision.SectorRematcher; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.slf4j.Logger; @@ -25,6 +31,7 @@ public class UpdateReleaseTool implements AutoCloseable { final HikariDataSource dataSource; final Dataset release; final Dataset project; + final DatasetSettings settings; final int userKey; public UpdateReleaseTool(int releaseKey, PgConfig cfg, int userKey) { @@ -40,6 +47,7 @@ public UpdateReleaseTool(int releaseKey, PgConfig cfg, int userKey) { throw new IllegalArgumentException("Dataset key "+releaseKey+" is not a release!"); } project = dm.get(release.getSourceKey()); + settings = dm.getSettings(project.getKey()); } } @@ -49,8 +57,8 @@ public UpdateReleaseTool(int releaseKey, PgConfig cfg, int userKey) { public void rebuildSourceMetadata(){ System.out.printf("%s: %s\n\n", release.getKey(), release.getCitation()); DatasetProjectSourceDao dao = new DatasetProjectSourceDao(factory); - //show(dao); - update(dao); + show(dao); + //update(dao); } /** @@ -80,6 +88,12 @@ public void rematchSectorTargets(){ } void show(DatasetProjectSourceDao dao){ + System.out.printf("%s\n", release.getCitation()); + if (settings.has(Setting.RELEASE_CITATION_TEMPLATE)) { + String citation = CitationUtils.fromTemplate(release, settings.getString(Setting.RELEASE_CITATION_TEMPLATE)); + release.setCitation(citation); + } + System.out.printf("%s\n", release.getCitation()); dao.list(release.getKey(), release, true).forEach(d -> { System.out.printf("%s: %s\n", d.getKey(), d.getCitation()); }); diff --git a/webservice/src/main/java/life/catalogue/WsServer.java b/webservice/src/main/java/life/catalogue/WsServer.java index 58c0cb9cd9..325de75701 100644 --- a/webservice/src/main/java/life/catalogue/WsServer.java +++ b/webservice/src/main/java/life/catalogue/WsServer.java @@ -17,10 +17,7 @@ import life.catalogue.api.jackson.ApiModule; import life.catalogue.api.vocab.ColDwcTerm; import life.catalogue.assembly.AssemblyCoordinator; -import life.catalogue.command.AddTableCmd; -import life.catalogue.command.ExecSqlCmd; -import life.catalogue.command.IndexCmd; -import life.catalogue.command.InitDbCmd; +import life.catalogue.command.*; import life.catalogue.common.concurrent.JobExecutor; import life.catalogue.common.csl.CslUtil; import life.catalogue.common.io.DownloadUtil; @@ -109,10 +106,13 @@ public void initialize(Bootstrap bootstrap) { bootstrap.setObjectMapper(om); // add some cli commands not accessible via the admin interface - bootstrap.addCommand(new InitDbCmd()); - bootstrap.addCommand(new IndexCmd()); bootstrap.addCommand(new AddTableCmd()); bootstrap.addCommand(new ExecSqlCmd()); + bootstrap.addCommand(new IndexCmd()); + bootstrap.addCommand(new InitDbCmd()); + bootstrap.addCommand(new NamesIndexCmd()); + bootstrap.addCommand(new RebuiltSourceCitationCmd()); + } @Override