Commit 2042311b authored by Matija Obreza's avatar Matija Obreza

Fix: Download DwCA archive failed

parent 8af0a8d1
......@@ -50,8 +50,6 @@ public interface GenesysLowlevelRepository {
void listAccessionsAlias(AppliedFilters filter, RowCallbackHandler rowCallbackHandler);
void listAccessionsAccenames(RowCallbackHandler rowCallbackHandler);
void listAccessionsAlias(RowCallbackHandler rowCallbackHandler);
int countAccessions(AppliedFilters filter);
......@@ -60,6 +58,4 @@ public interface GenesysLowlevelRepository {
void updateAccessionSequentialNumber(List<Object[]> data);
void listFullTextSearchEntitiesIds(String className, RowCallbackHandler rowCallbackHandler);
}
......@@ -244,8 +244,8 @@ public class GenesysLowlevelRepositoryCustomImpl implements GenesysLowlevelRepos
@Override
public PreparedStatement createPreparedStatement(final Connection con) throws SQLException {
final PreparedStatement stmt = con.prepareStatement(directQuery
.getQuery("a.id, acce.uuid, a.instCode, a.acceNumb, a.doi, t.genus, t.species, t.spAuthor, t.subtaxa, t.subtAuthor, t.taxonName, a.orgCty, " +
"a.acqSrc, a.acqDate, a.mlsStat, a.available, a.historic, a.storage, a.sampStat, a.duplSite, " +
.getQuery("a.id, acce.uuid, a.instCode, a.acceNumb, a.doi, t.genus, t.species, t.spAuthor, t.subtaxa, t.subtAuthor, t.taxonName, a.origCty, " +
"a.acqSrc, a.acqDate, a.mlsStat, a.available, a.historic, a.storageStr, a.sampStat, a.duplSiteStr, " +
"acce.createdBy, acce.createdDate, acce.lastModifiedBy, acce.lastModifiedDate"));
final ArgumentPreparedStatementSetter apss = new ArgumentPreparedStatementSetter(directQuery.getParameters());
......@@ -286,8 +286,9 @@ public class GenesysLowlevelRepositoryCustomImpl implements GenesysLowlevelRepos
@Override
public void listAccessionsGeo(final AppliedFilters filter, final RowCallbackHandler rowCallbackHandler) {
final DirectMysqlQuery directQuery = new DirectMysqlQuery("accessiongeo", "geo");
directQuery.innerJoin("accession", "a", "a.id=geo.accessionId");
final DirectMysqlQuery directQuery = new DirectMysqlQuery("acce", "acce");
directQuery.innerJoin("accession_geo", "geo", "geo.id=acce.geoId");
directQuery.innerJoin("accession", "a", "a.id=acce.id");
directQuery.jsonFilter(filter, new MethodResolver() {
@Override
public Method getMethod(final long methodId) {
......@@ -314,7 +315,7 @@ public class GenesysLowlevelRepositoryCustomImpl implements GenesysLowlevelRepos
@Override
public void listAccessionsAlias(final AppliedFilters filter, final RowCallbackHandler rowCallbackHandler) {
// from n inner join accession a on a.id=n.accessionId
final DirectMysqlQuery directQuery = new DirectMysqlQuery("accessionalias", "n");
final DirectMysqlQuery directQuery = new DirectMysqlQuery("accession_alias", "n");
directQuery.innerJoin("accession", "a", "a.id=n.accessionId");
directQuery.jsonFilter(filter, new MethodResolver() {
@Override
......@@ -326,7 +327,7 @@ public class GenesysLowlevelRepositoryCustomImpl implements GenesysLowlevelRepos
this.jdbcTemplate.query(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(final Connection con) throws SQLException {
final PreparedStatement stmt = con.prepareStatement(directQuery.getQuery("a.id, n.instCode, n.name, n.aliasType, n.lang, n.version"));
final PreparedStatement stmt = con.prepareStatement(directQuery.getQuery("a.id, n.usedBy, n.name, n.aliasType, n.lang, n.version"));
final ArgumentPreparedStatementSetter apss = new ArgumentPreparedStatementSetter(directQuery.getParameters());
apss.setValues(stmt);
......@@ -344,7 +345,7 @@ public class GenesysLowlevelRepositoryCustomImpl implements GenesysLowlevelRepos
@Override
public PreparedStatement createPreparedStatement(final Connection con) throws SQLException {
final PreparedStatement stmt = con
.prepareStatement("select n.accessionId, n.instCode, n.name, n.aliasType, n.lang, n.version, n.id from accessionalias n order by n.accessionId");
.prepareStatement("select n.accessionId, n.instCode, n.name, n.aliasType, n.lang, n.version, n.id from accession_alias n order by n.accessionId");
// Set mysql JConnector to stream results
stmt.setFetchSize(Integer.MIN_VALUE);
return stmt;
......@@ -354,10 +355,9 @@ public class GenesysLowlevelRepositoryCustomImpl implements GenesysLowlevelRepos
@Override
public void listAccessionsColl(final AppliedFilters filter, final RowCallbackHandler rowCallbackHandler) {
// from accessioncollect coll inner join accession a on
// a.id=coll.accessionId
final DirectMysqlQuery directQuery = new DirectMysqlQuery("accessioncollect", "coll");
directQuery.innerJoin("accession", "a", "a.id=coll.accessionId");
final DirectMysqlQuery directQuery = new DirectMysqlQuery("acce", "acce");
directQuery.innerJoin("accession_collect", "coll", "coll.id=acce.collId");
directQuery.innerJoin("accession", "a", "a.id=acce.id");
directQuery.jsonFilter(filter, new MethodResolver() {
@Override
public Method getMethod(final long methodId) {
......@@ -369,7 +369,8 @@ public class GenesysLowlevelRepositoryCustomImpl implements GenesysLowlevelRepos
@Override
public PreparedStatement createPreparedStatement(final Connection con) throws SQLException {
final PreparedStatement stmt = con.prepareStatement(directQuery
.getQuery("a.id, coll.collMissId, coll.collNumb, coll.collDate, coll.collSrc, coll.collSite, coll.collCode, coll.collName, coll.collInstAddress, coll.version"));
//.getQuery("a.id, coll.collMissId, coll.collNumb, coll.collDate, coll.collSrc, coll.collSite, coll.collCode, coll.collName, coll.collInstAddress, coll.version"));
.getQuery("a.id, coll.collMissId, coll.collNumb, coll.collDate, coll.collSrc, coll.collSite, coll.version"));
final ArgumentPreparedStatementSetter apss = new ArgumentPreparedStatementSetter(directQuery.getParameters());
apss.setValues(stmt);
......@@ -396,19 +397,6 @@ public class GenesysLowlevelRepositoryCustomImpl implements GenesysLowlevelRepos
}, rowCallbackHandler);
}
@Override
public void listAccessionsAccenames(final RowCallbackHandler rowCallbackHandler) {
this.jdbcTemplate.query(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(final Connection con) throws SQLException {
final PreparedStatement stmt = con.prepareStatement("select accessionId, names, otherIds from accessionname");
// Set mysql JConnector to stream results
stmt.setFetchSize(Integer.MIN_VALUE);
return stmt;
}
}, rowCallbackHandler);
}
/**
* Data[] = accessionId, acceNumb and seqNo
*/
......@@ -431,18 +419,4 @@ public class GenesysLowlevelRepositoryCustomImpl implements GenesysLowlevelRepos
}
});
}
@Override
public void listFullTextSearchEntitiesIds(String className, RowCallbackHandler rowCallbackHandler) {
this.jdbcTemplate.query(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(final Connection con) throws SQLException {
String query = "select * from " + className.toLowerCase();
// Set mysql JConnector to stream results
// stmt.setFetchSize(Integer.MIN_VALUE);
return con.prepareStatement(query);
}
}, rowCallbackHandler);
}
}
......@@ -1124,7 +1124,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
private void writeAccessionsCore(final AppliedFilters filters, ZipOutputStream zos) throws IOException {
@SuppressWarnings("resource")
final CSVWriter csv = new CSVWriter(new BufferedWriter(new OutputStreamWriter(zos)), ',', '"', '\\', "\n");
csv.writeNext(new String[] { "genesysId", "uuid", "instCode", "acceNumb", "doi", "genus", "species", "spAuthor", "subtaxa", "subtAuthor", "fullTaxa", "orgCty", "acqSrc", "acqDate", "mlsStat", "available", "historic",
csv.writeNext(new String[] { "genesysId", "uuid", "instCode", "acceNumb", "doi", "genus", "species", "spAuthor", "subtaxa", "subtAuthor", "fullTaxa", "origCty", "acqSrc", "acqDate", "mlsStat", "available", "historic",
"storage", "sampStat", "duplSite", "createdBy", "createdDate", "lastModifiedBy", "lastModifiedDate" });
final ResultSetHelper csvResultsetHelper = new CSVResultSetHelper();
......@@ -1215,7 +1215,8 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
private void writeAccessionsColl(final AppliedFilters filters, ZipOutputStream zos) throws IOException {
@SuppressWarnings("resource")
final CSVWriter csv = new CSVWriter(new BufferedWriter(new OutputStreamWriter(zos)), ',', '"', '\\', "\n");
csv.writeNext(new String[] { "genesysId", "collMissId", "collNumb", "collDate", "collSrc", "collSite", "collCode", "collName", "collInstAddress", "version" });
// csv.writeNext(new String[] { "genesysId", "collMissId", "collNumb", "collDate", "collSrc", "collSite", "collCode", "collName", "collInstAddress", "version" });
csv.writeNext(new String[] { "genesysId", "collMissId", "collNumb", "collDate", "collSrc", "collSite", "version" });
final ResultSetHelper csvResultsetHelper = new ResultSetHelperService();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment