Permalink
Browse files

fixed increase popularity task

  • Loading branch information...
1 parent 54bea3d commit f01482878284c851184f3dbdf4b63f0c9d097d0e @jesseeichar jesseeichar committed Feb 20, 2013
Showing with 2 additions and 38 deletions.
  1. +2 −38 web/src/main/java/org/fao/geonet/kernel/DataManager.java
@@ -3274,7 +3274,7 @@ public void saveCustomElementSets(Dbms dbms, CustomElementSet customElementSet)
/**
* TODO javadoc.
*/
- class IncreasePopularityTask implements Runnable, UpdateIndexFunction {
+ class IncreasePopularityTask implements Runnable {
private ServiceContext srvContext;
String id;
private String updatedPopularity;
@@ -3297,7 +3297,7 @@ public void run() {
String updateQuery = "UPDATE Metadata SET popularity = popularity +1 WHERE id = ?";
Integer iId = new Integer(id);
dbms.execute(updateQuery, iId);
- searchMan.updateIndex(id, this);
+ indexMetadata(dbms, id);
}
catch (Exception e) {
Log.error(Geonet.DATA_MANAGER, "The following exception is ignored: " + e.getMessage());
@@ -3315,42 +3315,6 @@ public void run() {
}
- @Override
- public void prepareForUpdate() {
- Dbms dbms = null;
- try {
- dbms = (Dbms) srvContext.getResourceManager().openDirect(Geonet.Res.MAIN_DB);
- Integer iId = new Integer(id);
- String selectQuery = "SELECT popularity from Metadata where id = ?";
- Element result = dbms.select(selectQuery, iId).getChild("record");
- this.updatedPopularity = result.getChildText("popularity");
- }
- catch (Exception e) {
- Log.error(Geonet.DATA_MANAGER, "The following exception is ignored: " + e.getMessage());
- e.printStackTrace();
- }
- finally {
- try {
- if (dbms != null) srvContext.getResourceManager().close(Geonet.Res.MAIN_DB, dbms);
- }
- catch (Exception e) {
- Log.error(Geonet.DATA_MANAGER, "There may have been an error updating the popularity of the metadata "+id+". Error: " + e.getMessage());
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public org.apache.lucene.document.Document update(String indexLanguage,
- org.apache.lucene.document.Document currentDocument) {
- String fieldName = "_popularity";
- currentDocument.removeFields(fieldName);
-
- // TODO check config if popularity becomes a numeric
- Field field = new Field(fieldName, this.updatedPopularity, Store.YES, Index.NOT_ANALYZED);
- currentDocument.add(field);
- return currentDocument;
- }
}
public enum UpdateDatestamp {
yes, no

0 comments on commit f014828

Please sign in to comment.