Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java @ 308:a077bb098eb4
Fixed broken SQL statement. Added debug output.
artifacts/trunk@2427 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 31 Jul 2011 17:28:07 +0000 |
parents | d96bcb40dbf9 |
children | 86dd32b45d87 |
comparison
equal
deleted
inserted
replaced
307:d96bcb40dbf9 | 308:a077bb098eb4 |
---|---|
17 import de.intevation.artifacts.User; | 17 import de.intevation.artifacts.User; |
18 import de.intevation.artifacts.UserFactory; | 18 import de.intevation.artifacts.UserFactory; |
19 | 19 |
20 import de.intevation.artifacts.common.utils.StringUtils; | 20 import de.intevation.artifacts.common.utils.StringUtils; |
21 import de.intevation.artifacts.common.utils.XMLUtils; | 21 import de.intevation.artifacts.common.utils.XMLUtils; |
22 import de.intevation.artifacts.common.utils.LRUCache; | |
22 | 23 |
23 import de.intevation.artifactdatabase.db.SQLExecutor; | 24 import de.intevation.artifactdatabase.db.SQLExecutor; |
24 import de.intevation.artifactdatabase.db.SQL; | 25 import de.intevation.artifactdatabase.db.SQL; |
25 | 26 |
26 import java.sql.SQLException; | 27 import java.sql.SQLException; |
1566 }.runWrite(); | 1567 }.runWrite(); |
1567 } | 1568 } |
1568 | 1569 |
1569 public boolean loadAllArtifacts(final ArtifactLoadedCallback alc) { | 1570 public boolean loadAllArtifacts(final ArtifactLoadedCallback alc) { |
1570 | 1571 |
1572 logger.debug("loadAllArtifacts"); | |
1573 | |
1571 if (factoryLookup == null) { | 1574 if (factoryLookup == null) { |
1572 logger.error("factory lookup == null"); | 1575 logger.error("factory lookup == null"); |
1573 return false; | 1576 return false; |
1574 } | 1577 } |
1575 | 1578 |
1576 return sqlExecutor.new Instance() { | 1579 boolean success = sqlExecutor.new Instance() { |
1577 public boolean doIt() throws SQLException { | 1580 @Override |
1581 public boolean doIt() throws SQLException { | |
1582 logger.debug("doIt"); | |
1578 | 1583 |
1579 // a little cache to avoid too much deserializations. | 1584 // a little cache to avoid too much deserializations. |
1580 Map<String, Artifact> alreadyLoaded = | 1585 LRUCache<String, Artifact> alreadyLoaded = |
1581 new LinkedHashMap<String, Artifact>() { | 1586 new LRUCache<String, Artifact>(200); |
1582 @Override | |
1583 protected boolean removeEldestEntry(Map.Entry eldest) { | |
1584 // store only the last 200 to avoid memory flooding | |
1585 return size() > 200; | |
1586 } | |
1587 }; | |
1588 | 1587 |
1589 prepareStatement(SQL_ALL_ARTIFACTS); | 1588 prepareStatement(SQL_ALL_ARTIFACTS); |
1590 result = stmnt.executeQuery(); | 1589 result = stmnt.executeQuery(); |
1591 while (result.next()) { | 1590 while (result.next()) { |
1592 String userId = result.getString(1); | 1591 String userId = result.getString(1); |
1622 alreadyLoaded.put(artifactId, artifact); | 1621 alreadyLoaded.put(artifactId, artifact); |
1623 } | 1622 } |
1624 return true; | 1623 return true; |
1625 } | 1624 } |
1626 }.runRead(); | 1625 }.runRead(); |
1626 | |
1627 if (logger.isDebugEnabled()) { | |
1628 logger.debug("loadAllArtifacts success: " + success); | |
1629 } | |
1630 | |
1631 return success; | |
1627 } | 1632 } |
1628 } | 1633 } |
1629 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 1634 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |