Skip to content

Commit

Permalink
Add 2 new commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoering committed Dec 4, 2020
1 parent 321e7a8 commit c205dc3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
20 changes: 17 additions & 3 deletions dao/src/main/java/life/catalogue/tools/UpdateReleaseTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@

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;
import life.catalogue.db.mapper.DatasetMapper;
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;
Expand All @@ -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) {
Expand All @@ -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());
}
}

Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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());
});
Expand Down
12 changes: 6 additions & 6 deletions webservice/src/main/java/life/catalogue/WsServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -109,10 +106,13 @@ public void initialize(Bootstrap<WsServerConfig> 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
Expand Down

0 comments on commit c205dc3

Please sign in to comment.