Commit c1d772c6 authored by Matija Obreza's avatar Matija Obreza
Browse files

Use directQuery to generate DwCA files from filtered data

parent 67ccd57d
...@@ -21,6 +21,8 @@ import org.genesys2.server.model.impl.Country; ...@@ -21,6 +21,8 @@ import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.FaoInstitute; import org.genesys2.server.model.impl.FaoInstitute;
import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.jdbc.core.RowCallbackHandler;
import com.fasterxml.jackson.databind.node.ObjectNode;
public interface GenesysLowlevelRepository { public interface GenesysLowlevelRepository {
void updateCountryRefs(); void updateCountryRefs();
...@@ -38,15 +40,15 @@ public interface GenesysLowlevelRepository { ...@@ -38,15 +40,15 @@ public interface GenesysLowlevelRepository {
void refreshMetadataMethods(); void refreshMetadataMethods();
void listAccessions(String instCode, RowCallbackHandler rowCallbackHandler); void listAccessions(ObjectNode filter, RowCallbackHandler rowCallbackHandler);
void listAccessionsGeo(String code, RowCallbackHandler rowCallbackHandler); void listAccessionsGeo(ObjectNode filter, RowCallbackHandler rowCallbackHandler);
void listAccessionsColl(String code, RowCallbackHandler rowCallbackHandler); void listAccessionsColl(ObjectNode filter, RowCallbackHandler rowCallbackHandler);
void listMetadataAccessions(long id, RowCallbackHandler rowCallbackHandler); void listMetadataAccessions(long id, RowCallbackHandler rowCallbackHandler);
void listAccessionsAlias(String code, RowCallbackHandler rowCallbackHandler); void listAccessionsAlias(ObjectNode filter, RowCallbackHandler rowCallbackHandler);
void listAccessionsAccenames(RowCallbackHandler rowCallbackHandler); void listAccessionsAccenames(RowCallbackHandler rowCallbackHandler);
......
...@@ -28,8 +28,11 @@ import javax.sql.DataSource; ...@@ -28,8 +28,11 @@ import javax.sql.DataSource;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.genesys2.server.model.genesys.Method; import org.genesys2.server.model.genesys.Method;
import org.genesys2.server.service.impl.DirectMysqlQuery;
import org.genesys2.server.service.impl.DirectMysqlQuery.MethodResolver;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.BadSqlGrammarException; import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.jdbc.core.ArgumentPreparedStatementSetter;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCreator; import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.jdbc.core.RowCallbackHandler;
...@@ -37,6 +40,8 @@ import org.springframework.security.access.prepost.PreAuthorize; ...@@ -37,6 +40,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.fasterxml.jackson.databind.node.ObjectNode;
@Repository @Repository
@Transactional(readOnly = true) @Transactional(readOnly = true)
public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository { public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository {
...@@ -44,6 +49,9 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository ...@@ -44,6 +49,9 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Autowired
private MethodRepository methodRepository;
@Autowired @Autowired
public void setDataSource(final DataSource dataSource) { public void setDataSource(final DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate = new JdbcTemplate(dataSource);
...@@ -67,12 +75,11 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository ...@@ -67,12 +75,11 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository
@Transactional(readOnly = false) @Transactional(readOnly = false)
public void updateInstituteAccessionCount(long instituteId) { public void updateInstituteAccessionCount(long instituteId) {
LOG.info("Updating institute accession count for instituteId=" + instituteId); LOG.info("Updating institute accession count for instituteId=" + instituteId);
// int count = jdbcTemplate // int count = jdbcTemplate
// .update("UPDATE faoinstitute FI inner join (select instituteId, count(*) X from accession where instituteId= ? group by instituteId) A on A.instituteId=FI.id set FI.accessionCount=A.X where FI.id = ?;", // .update("UPDATE faoinstitute FI inner join (select instituteId, count(*) X from accession where instituteId= ? group by instituteId) A on A.instituteId=FI.id set FI.accessionCount=A.X where FI.id = ?;",
// instituteId, instituteId); // instituteId, instituteId);
int count = jdbcTemplate int count = jdbcTemplate.update("UPDATE faoinstitute SET accessionCount = (select count(*) from accession where instituteId=?) where id = ?;",
.update("UPDATE faoinstitute SET accessionCount = (select count(*) from accession where instituteId=?) where id = ?;", instituteId, instituteId);
instituteId, instituteId);
LOG.info("Institute accession counts updated: " + count); LOG.info("Institute accession counts updated: " + count);
} }
...@@ -208,13 +215,25 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository ...@@ -208,13 +215,25 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository
} }
@Override @Override
public void listAccessions(final String instCode, RowCallbackHandler rowCallbackHandler) { public void listAccessions(final ObjectNode filter, RowCallbackHandler rowCallbackHandler) {
final DirectMysqlQuery directQuery = new DirectMysqlQuery("accession", "a");
directQuery.outerJoin("taxonomy2", "t", "t.id=a.taxonomyId2");
directQuery.jsonFilter(filter, new MethodResolver() {
@Override
public Method getMethod(long methodId) {
return methodRepository.findOne(methodId);
}
});
jdbcTemplate.query(new PreparedStatementCreator() { jdbcTemplate.query(new PreparedStatementCreator() {
@Override @Override
public PreparedStatement createPreparedStatement(Connection con) throws SQLException { public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
PreparedStatement stmt = con PreparedStatement stmt = con.prepareStatement(directQuery
.prepareStatement("select a.id, a.uuid, a.instCode, a.acceNumb, a.genus, t.species, a.orgCty, a.acqSrc, a.acqDate, a.mlsStat, a.available, a.storage, a.sampStat, a.duplSite, a.createdBy, a.createdDate, a.lastModifiedBy, a.lastModifiedDate from accession a left outer join taxonomy t on t.id=a.taxonomyId where a.instCode = ?"); .getQuery("a.id, a.uuid, a.instCode, a.acceNumb, t.genus, t.species, t.taxonName, a.orgCty, a.acqSrc, a.acqDate, a.mlsStat, a.available, a.storage, a.sampStat, a.duplSite, a.createdBy, a.createdDate, a.lastModifiedBy, a.lastModifiedDate"));
stmt.setString(1, instCode);
ArgumentPreparedStatementSetter apss = new ArgumentPreparedStatementSetter(directQuery.getParameters());
apss.setValues(stmt);
// Set mysql JConnector to stream results // Set mysql JConnector to stream results
stmt.setFetchSize(Integer.MIN_VALUE); stmt.setFetchSize(Integer.MIN_VALUE);
return stmt; return stmt;
...@@ -223,13 +242,25 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository ...@@ -223,13 +242,25 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository
} }
@Override @Override
public void listAccessionsGeo(final String instCode, RowCallbackHandler rowCallbackHandler) { public void listAccessionsGeo(final ObjectNode filter, RowCallbackHandler rowCallbackHandler) {
final DirectMysqlQuery directQuery = new DirectMysqlQuery("accessiongeo", "g");
directQuery.innerJoin("accession", "a", "a.id=g.accessionId");
directQuery.jsonFilter(filter, new MethodResolver() {
@Override
public Method getMethod(long methodId) {
return methodRepository.findOne(methodId);
}
});
jdbcTemplate.query(new PreparedStatementCreator() { jdbcTemplate.query(new PreparedStatementCreator() {
@Override @Override
public PreparedStatement createPreparedStatement(Connection con) throws SQLException { public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
PreparedStatement stmt = con PreparedStatement stmt = con.prepareStatement(directQuery
.prepareStatement("select a.id, g.latitude, g.longitude, g.elevation, g.datum, g.uncertainty, g.method, g.version from accessiongeo g inner join accession a on a.id=g.accessionId where a.instCode = ?"); .getQuery("a.id, g.latitude, g.longitude, g.elevation, g.datum, g.uncertainty, g.method, g.version"));
stmt.setString(1, instCode);
ArgumentPreparedStatementSetter apss = new ArgumentPreparedStatementSetter(directQuery.getParameters());
apss.setValues(stmt);
// Set mysql JConnector to stream results // Set mysql JConnector to stream results
stmt.setFetchSize(Integer.MIN_VALUE); stmt.setFetchSize(Integer.MIN_VALUE);
return stmt; return stmt;
...@@ -238,13 +269,26 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository ...@@ -238,13 +269,26 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository
} }
@Override @Override
public void listAccessionsAlias(final String instCode, RowCallbackHandler rowCallbackHandler) { public void listAccessionsAlias(final ObjectNode filter, RowCallbackHandler rowCallbackHandler) {
//from n inner join accession a on a.id=n.accessionId
final DirectMysqlQuery directQuery = new DirectMysqlQuery("accessionalias", "n");
directQuery.innerJoin("accession", "a", "a.id=n.accessionId");
directQuery.jsonFilter(filter, new MethodResolver() {
@Override
public Method getMethod(long methodId) {
return methodRepository.findOne(methodId);
}
});
jdbcTemplate.query(new PreparedStatementCreator() { jdbcTemplate.query(new PreparedStatementCreator() {
@Override @Override
public PreparedStatement createPreparedStatement(Connection con) throws SQLException { public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
PreparedStatement stmt = con PreparedStatement stmt = con
.prepareStatement("select a.id, n.instCode, n.name, n.aliasType, n.lang, n.version from accessionalias n inner join accession a on a.id=n.accessionId where a.instCode = ?"); .prepareStatement(directQuery.getQuery("a.id, n.instCode, n.name, n.aliasType, n.lang, n.version"));
stmt.setString(1, instCode);
ArgumentPreparedStatementSetter apss = new ArgumentPreparedStatementSetter(directQuery.getParameters());
apss.setValues(stmt);
// Set mysql JConnector to stream results // Set mysql JConnector to stream results
stmt.setFetchSize(Integer.MIN_VALUE); stmt.setFetchSize(Integer.MIN_VALUE);
return stmt; return stmt;
...@@ -268,13 +312,26 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository ...@@ -268,13 +312,26 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository
} }
@Override @Override
public void listAccessionsColl(final String instCode, RowCallbackHandler rowCallbackHandler) { public void listAccessionsColl(final ObjectNode filter, 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");
directQuery.jsonFilter(filter, new MethodResolver() {
@Override
public Method getMethod(long methodId) {
return methodRepository.findOne(methodId);
}
});
jdbcTemplate.query(new PreparedStatementCreator() { jdbcTemplate.query(new PreparedStatementCreator() {
@Override @Override
public PreparedStatement createPreparedStatement(Connection con) throws SQLException { public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
PreparedStatement stmt = con PreparedStatement stmt = con
.prepareStatement("select a.id, coll.collMissId, coll.collNumb, coll.collDate, coll.collSrc, coll.collSite, coll.collCode, coll.collName, coll.collInstAddress, coll.version from accessioncollect coll inner join accession a on a.id=coll.accessionId where a.instCode = ?"); .prepareStatement(directQuery.getQuery("a.id, coll.collMissId, coll.collNumb, coll.collDate, coll.collSrc, coll.collSite, coll.collCode, coll.collName, coll.collInstAddress, coll.version"));
stmt.setString(1, instCode);
ArgumentPreparedStatementSetter apss = new ArgumentPreparedStatementSetter(directQuery.getParameters());
apss.setValues(stmt);
// Set mysql JConnector to stream results // Set mysql JConnector to stream results
stmt.setFetchSize(Integer.MIN_VALUE); stmt.setFetchSize(Integer.MIN_VALUE);
return stmt; return stmt;
......
...@@ -145,6 +145,8 @@ public interface GenesysService { ...@@ -145,6 +145,8 @@ public interface GenesysService {
void writeAccessions(FaoInstitute faoInstitute, OutputStream outputStream) throws IOException; void writeAccessions(FaoInstitute faoInstitute, OutputStream outputStream) throws IOException;
void writeAccessions(String jsonFilter, OutputStream outputStream) throws IOException;
void saveAliases(List<AccessionAlias> aliases); void saveAliases(List<AccessionAlias> aliases);
void removeAliases(List<AccessionAlias> aliases); void removeAliases(List<AccessionAlias> aliases);
......
...@@ -50,6 +50,24 @@ public class DirectMysqlQuery { ...@@ -50,6 +50,24 @@ public class DirectMysqlQuery {
return this; return this;
} }
public DirectMysqlQuery outerJoin(String table, String alias, String onExpr) {
if (tables.contains(table)) {
LOG.warn("Table already joined: " + table);
return this;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Leftouter-joining " + table + " " + alias + " on " + onExpr);
}
sb.append(" left outer join ").append(table).append(StringUtils.SPACE);
tables.add(table);
if (StringUtils.isNotBlank(alias)) {
sb.append(alias).append(StringUtils.SPACE);
}
sb.append("on ").append(onExpr).append(StringUtils.SPACE);
return this;
}
public DirectMysqlQuery jsonFilter(ObjectNode jsonTree, MethodResolver methodResolver) { public DirectMysqlQuery jsonFilter(ObjectNode jsonTree, MethodResolver methodResolver) {
return join(jsonTree).filter(jsonTree, methodResolver); return join(jsonTree).filter(jsonTree, methodResolver);
} }
...@@ -95,7 +113,9 @@ public class DirectMysqlQuery { ...@@ -95,7 +113,9 @@ public class DirectMysqlQuery {
for (Iterator<String> it = jsonTree.fieldNames(); it.hasNext();) { for (Iterator<String> it = jsonTree.fieldNames(); it.hasNext();) {
String fieldName = it.next(); String fieldName = it.next();
if (fieldName.startsWith("gm:")) { if (fieldName.startsWith("gm:")) {
LOG.info("Filtering on C&E data, method=" + fieldName); if (LOG.isDebugEnabled()) {
LOG.debug("Filtering on C&E data, method=" + fieldName);
}
// Handle Genesys Method! // Handle Genesys Method!
long methodId = Long.parseLong(fieldName.substring(3)); long methodId = Long.parseLong(fieldName.substring(3));
// Need to validate method // Need to validate method
...@@ -110,15 +130,19 @@ public class DirectMysqlQuery { ...@@ -110,15 +130,19 @@ public class DirectMysqlQuery {
} }
} }
LOG.info("Parameter count: " + params.size()); if (LOG.isDebugEnabled()) {
LOG.info("Count query:\n" + sb.toString()); LOG.debug("Parameter count: " + params.size());
LOG.debug("Count query:\n" + sb.toString());
}
return this; return this;
} }
public void filterTile(int zoom, int xtile, int ytile) { public void filterTile(int zoom, int xtile, int ytile) {
if (zoom >= 0) { if (zoom >= 0) {
LOG.debug("ZOOM=" + zoom); if (LOG.isDebugEnabled()) {
LOG.debug("ZOOM=" + zoom);
}
final double lonW = CoordUtil.tileToLon(zoom, xtile); final double lonW = CoordUtil.tileToLon(zoom, xtile);
final double lonE = CoordUtil.tileToLon(zoom, xtile + 1); final double lonE = CoordUtil.tileToLon(zoom, xtile + 1);
final double diffLon = lonE - lonW; final double diffLon = lonE - lonW;
...@@ -144,9 +168,13 @@ public class DirectMysqlQuery { ...@@ -144,9 +168,13 @@ public class DirectMysqlQuery {
} }
private void createQuery(StringBuffer sb, String dbName, JsonNode fieldQuery, List<Object> params) { private void createQuery(StringBuffer sb, String dbName, JsonNode fieldQuery, List<Object> params) {
LOG.debug("Handling " + dbName); if (LOG.isDebugEnabled()) {
LOG.debug("Handling " + dbName);
}
if (fieldQuery != null) { if (fieldQuery != null) {
LOG.debug("Adding " + fieldQuery + " sz=" + fieldQuery.size() + " t=" + fieldQuery.getNodeType()); if (LOG.isDebugEnabled()) {
LOG.debug("Adding " + fieldQuery + " sz=" + fieldQuery.size() + " t=" + fieldQuery.getNodeType());
}
if (sb.length() == 0) if (sb.length() == 0)
sb.append(" where "); sb.append(" where ");
else else
...@@ -191,13 +219,19 @@ public class DirectMysqlQuery { ...@@ -191,13 +219,19 @@ public class DirectMysqlQuery {
int counter = 0; int counter = 0;
while (elements.hasNext()) { while (elements.hasNext()) {
JsonNode filterValue = elements.next(); JsonNode filterValue = elements.next();
LOG.debug("Inspecting " + dbName + " ... " + filterValue); if (LOG.isDebugEnabled()) {
LOG.debug("Inspecting " + dbName + " ... " + filterValue);
}
if (filterValue.isObject()) { if (filterValue.isObject()) {
LOG.debug("Adding " + filterValue); if (LOG.isDebugEnabled()) {
LOG.debug("Adding " + filterValue);
}
JsonNode range = filterValue.findValue("range"); JsonNode range = filterValue.findValue("range");
if (range != null && range.isArray()) { if (range != null && range.isArray()) {
LOG.debug("Adding array: " + range); if (LOG.isDebugEnabled()) {
LOG.debug("Adding array: " + range);
}
if (counter > 0) { if (counter > 0) {
sb.append(" or "); sb.append(" or ");
} }
...@@ -211,7 +245,9 @@ public class DirectMysqlQuery { ...@@ -211,7 +245,9 @@ public class DirectMysqlQuery {
JsonNode min = filterValue.findValue("min"); JsonNode min = filterValue.findValue("min");
if (min != null && min.isNumber()) { if (min != null && min.isNumber()) {
LOG.debug("Adding min number: " + min); if (LOG.isDebugEnabled()) {
LOG.debug("Adding min number: " + min);
}
if (counter > 0) { if (counter > 0) {
sb.append(" or "); sb.append(" or ");
} }
...@@ -224,7 +260,9 @@ public class DirectMysqlQuery { ...@@ -224,7 +260,9 @@ public class DirectMysqlQuery {
JsonNode max = filterValue.findValue("max"); JsonNode max = filterValue.findValue("max");
if (max != null && max.isNumber()) { if (max != null && max.isNumber()) {
LOG.debug("Adding max number: " + max); if (LOG.isDebugEnabled()) {
LOG.debug("Adding max number: " + max);
}
if (counter > 0) { if (counter > 0) {
sb.append(" or "); sb.append(" or ");
} }
...@@ -237,7 +275,9 @@ public class DirectMysqlQuery { ...@@ -237,7 +275,9 @@ public class DirectMysqlQuery {
JsonNode like = filterValue.findValue("like"); JsonNode like = filterValue.findValue("like");
if (like != null && like.isTextual()) { if (like != null && like.isTextual()) {
LOG.debug("Adding LIKE : " + like); if (LOG.isDebugEnabled()) {
LOG.debug("Adding LIKE : " + like);
}
if (counter > 0) { if (counter > 0) {
sb.append(" or "); sb.append(" or ");
} }
...@@ -258,9 +298,13 @@ public class DirectMysqlQuery { ...@@ -258,9 +298,13 @@ public class DirectMysqlQuery {
int counter = 0; int counter = 0;
while (elements.hasNext()) { while (elements.hasNext()) {
JsonNode filterValue = elements.next(); JsonNode filterValue = elements.next();
LOG.debug("Inspecting " + dbName + " ... " + filterValue); if (LOG.isDebugEnabled()) {
LOG.debug("Inspecting " + dbName + " ... " + filterValue);
}
if (filterValue.isNull()) { if (filterValue.isNull()) {
LOG.debug("Adding " + filterValue); if (LOG.isDebugEnabled()) {
LOG.debug("Adding " + filterValue);
}
counter++; counter++;
} }
} }
...@@ -277,9 +321,13 @@ public class DirectMysqlQuery { ...@@ -277,9 +321,13 @@ public class DirectMysqlQuery {
int counter = 0; int counter = 0;
while (elements.hasNext()) { while (elements.hasNext()) {
JsonNode filterValue = elements.next(); JsonNode filterValue = elements.next();
LOG.debug("Inspecting " + dbName + " ... " + filterValue); if (LOG.isDebugEnabled()) {
LOG.debug("Inspecting " + dbName + " ... " + filterValue);
}
if (filterValue.isNumber() || filterValue.isTextual() || filterValue.isBoolean()) { if (filterValue.isNumber() || filterValue.isTextual() || filterValue.isBoolean()) {
LOG.debug("Adding " + filterValue); if (LOG.isDebugEnabled()) {
LOG.debug("Adding " + filterValue);
}
counter++; counter++;
addParam(params, filterValue); addParam(params, filterValue);
} }
...@@ -311,7 +359,9 @@ public class DirectMysqlQuery { ...@@ -311,7 +359,9 @@ public class DirectMysqlQuery {
} }
public String getCountQuery(String countWhat) { public String getCountQuery(String countWhat) {
LOG.info("select count(" + countWhat + ") " + sb.toString() + " " + whereBuffer.toString()); if (LOG.isDebugEnabled()) {
LOG.debug("select count(" + countWhat + ") " + sb.toString() + " " + whereBuffer.toString());
}
return "select count(" + countWhat + ") " + sb.toString() + " " + whereBuffer.toString(); return "select count(" + countWhat + ") " + sb.toString() + " " + whereBuffer.toString();
} }
...@@ -331,7 +381,9 @@ public class DirectMysqlQuery { ...@@ -331,7 +381,9 @@ public class DirectMysqlQuery {
if (pageable.getSort() != null) { if (pageable.getSort() != null) {
sortBuffer.append("\n order by "); sortBuffer.append("\n order by ");
for (Order o : pageable.getSort()) { for (Order o : pageable.getSort()) {
LOG.debug("Order: " + o); if (LOG.isDebugEnabled()) {
LOG.debug("Order: " + o);
}
// ClassMetadata md = // ClassMetadata md =
// sessionFactory.getClassMetadata(Accession.class); // sessionFactory.getClassMetadata(Accession.class);
// md. // md.
...@@ -344,20 +396,26 @@ public class DirectMysqlQuery { ...@@ -344,20 +396,26 @@ public class DirectMysqlQuery {
} }
} }
sortBuffer.append(" limit "); sortBuffer.append(" limit ");
LOG.debug("Pageable=" + pageable.getOffset() + " " + pageable.getPageNumber()); if (LOG.isDebugEnabled()) {
LOG.debug("Pageable=" + pageable.getOffset() + " " + pageable.getPageNumber());
}
sortBuffer.append(pageable.getOffset()); sortBuffer.append(pageable.getOffset());
sortBuffer.append(", "); sortBuffer.append(", ");
sortBuffer.append(pageable.getPageSize()); sortBuffer.append(pageable.getPageSize());
LOG.info("Filter query:\n" + sb.toString()); if (LOG.isDebugEnabled()) {
LOG.info("Parameter count: " + params.size()); LOG.debug("Filter query:\n" + sb.toString());
LOG.info("Params: " + ArrayUtils.toString(params.toArray())); LOG.debug("Parameter count: " + params.size());
LOG.debug("Params: " + ArrayUtils.toString(params.toArray()));
}
return this; return this;
} }
public String getQuery(String what) { public String getQuery(String what) {
LOG.info("select " + what + " " + sb.toString() + " " + whereBuffer.toString() + " " + sortBuffer.toString()); if (LOG.isDebugEnabled()) {
LOG.debug("select " + what + " " + sb.toString() + " " + whereBuffer.toString() + " " + sortBuffer.toString());
}
return "select " + what + " " + sb.toString() + " " + whereBuffer.toString() + " " + sortBuffer.toString(); return "select " + what + " " + sb.toString() + " " + whereBuffer.toString() + " " + sortBuffer.toString();
} }
...@@ -373,4 +431,5 @@ public class DirectMysqlQuery { ...@@ -373,4 +431,5 @@ public class DirectMysqlQuery {
public static interface MethodResolver { public static interface MethodResolver {
Method getMethod(long methodId); Method getMethod(long methodId);
} }
} }
...@@ -25,6 +25,7 @@ import java.sql.SQLException; ...@@ -25,6 +25,7 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;