comparison artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java @ 345:7514fe89efef

Backend.getMasterArtifact: Limit result to one row. artifacts/trunk@3044 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 20 Oct 2011 10:13:46 +0000
parents be883e843539
children b7831cefbb62
comparison
equal deleted inserted replaced
344:be883e843539 345:7514fe89efef
1263 public String getMasterArtifact(final String collectionId) { 1263 public String getMasterArtifact(final String collectionId) {
1264 if (!isValidIdentifier(collectionId)) { 1264 if (!isValidIdentifier(collectionId)) {
1265 logger.debug("Invalid collection id: '" + collectionId + "'"); 1265 logger.debug("Invalid collection id: '" + collectionId + "'");
1266 return null; 1266 return null;
1267 } 1267 }
1268 final List<String> uuid = new ArrayList<String>(); 1268 final String [] uuid = new String[1];
1269
1269 SQLExecutor.Instance exec = sqlExecutor.new Instance() { 1270 SQLExecutor.Instance exec = sqlExecutor.new Instance() {
1270 public boolean doIt() throws SQLException { 1271 public boolean doIt() throws SQLException {
1271 // Fetch masters (oldest artifact) id. 1272 // Fetch masters (oldest artifact) id.
1272 prepareStatement(SQL_COLLECTIONS_OLDEST_ARTIFACT); 1273 prepareStatement(SQL_COLLECTIONS_OLDEST_ARTIFACT);
1273 stmnt.setString(1, collectionId); 1274 stmnt.setString(1, collectionId);
1274 logger.debug("getMaster.execute"); 1275 stmnt.setMaxRows(1); //
1275 result = stmnt.executeQuery(); 1276 result = stmnt.executeQuery();
1276 if (!result.next()) { 1277 if (!result.next()) {
1277 logger.debug("No such collection: " + collectionId); 1278 logger.debug("No such collection: " + collectionId);
1278 return false; 1279 return false;
1279 } 1280 }
1280 logger.debug("getMasterArtifact result.getString " + result.getString(1)); 1281 uuid[0] = result.getString(1);
1281 uuid.add(result.getString(1)); 1282 if (logger.isDebugEnabled()) {
1282 reset(); 1283 logger.debug("getMasterArtifact result.getString " +
1284 uuid[0]);
1285 }
1283 return true; 1286 return true;
1284 } 1287 }
1285 }; 1288 };
1286 return exec.runRead() ? uuid.get(0) : null; 1289 return exec.runRead() ? uuid[0] : null;
1287 } 1290 }
1288 1291
1289 public boolean deleteCollection(final String collectionId) { 1292 public boolean deleteCollection(final String collectionId) {
1290 if (!isValidIdentifier(collectionId)) { 1293 if (!isValidIdentifier(collectionId)) {
1291 logger.debug("Invalid collection id: '" + collectionId + "'"); 1294 logger.debug("Invalid collection id: '" + collectionId + "'");

http://dive4elements.wald.intevation.org