LOG.info("Reading existing pro parte nub usages {}from postgres ...", includeDeleted ? "incl. deleted " : "");
try (Writer writer = new ProParteUsageWriter()) {
cm.copyOut("COPY ("
+ "SELECT u.id, u.parent_fk, u.pp_synonym_fk, coalesce(NULLIF(trim(n.canonical_name), ''), n.scientific_name), n.authorship, n.year, u.rank, u.kingdom_fk, deleted is not null"
+ " FROM name_usage u join name n ON name_fk=n.id"
<BUG>+ " WHERE dataset_key = '" + Constants.NUB_DATASET_KEY + "'" + delClause + " AND pp_synonym_fk is not null)"
+ " TO STDOUT WITH NULL ''", writer);</BUG>
LOG.info("Added {} pro parte usages into id lookup", usages.size()-uCount);
}
LOG.info("Loaded existing nub with {} usages and max key {} into id lookup", usages.size(), keyMax);

LOG.info("Reading existing pro parte nub usages {}from postgres ...", includeDeleted ? "incl. deleted " : "");
try (Writer writer = new ProParteUsageWriter()) {
cm.copyOut("COPY ("
+ "SELECT u.id, u.parent_fk, u.pp_synonym_fk, coalesce(NULLIF(trim(n.canonical_name), ''), n.scientific_name), n.authorship, n.year, u.rank, u.kingdom_fk, deleted is not null"
+ " FROM name_usage u join name n ON name_fk=n.id"
+ " WHERE dataset_key = '" + Constants.NUB_DATASET_KEY + "'" + delClause + " AND pp_synonym_fk is not null)"
+ " ORDER BY pp_synonym_fk"
+ " TO STDOUT WITH NULL ''", writer);
LOG.info("Added {} pro parte usages into id lookup", usages.size()-uCount);
}
LOG.info("Loaded existing nub with {} usages and max key {} into id lookup", usages.size(), keyMax);
