-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9b7038
commit c29a875
Showing
17 changed files
with
373 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
rest/src/main/java/cz/incad/kramerius/rest/api/k5/client/SolrMemoization.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cz.incad.kramerius.rest.api.k5.client; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import org.w3c.dom.Element; | ||
|
||
/** | ||
* SOLR memoization support | ||
* @author pavels | ||
*/ | ||
public interface SolrMemoization { | ||
|
||
/** | ||
* Remember document from index | ||
* @param pid PID | ||
* @param elm W3C Element represents indexed document | ||
*/ | ||
public void rememberIndexedDoc(String pid, Element elm); | ||
|
||
/** | ||
* Returns remembered document | ||
* @param pid PID | ||
*/ | ||
public Element getRememberedIndexedDoc(String pid); | ||
|
||
/** | ||
* Ask SOLR for the index document | ||
* @param pid PID | ||
* @return | ||
* @throws IOException | ||
*/ | ||
public Element askForIndexDocument(String pid) throws IOException; | ||
|
||
/** | ||
* Clear remembered elements | ||
*/ | ||
public void clearMemo(); | ||
} |
8 changes: 8 additions & 0 deletions
8
rest/src/main/java/cz/incad/kramerius/rest/api/k5/client/SolrResultsAware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package cz.incad.kramerius.rest.api.k5.client; | ||
|
||
import java.util.List; | ||
|
||
public interface SolrResultsAware { | ||
|
||
public List<String> getFieldList(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
rest/src/main/java/cz/incad/kramerius/rest/api/k5/client/impl/SolrMemoizationImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package cz.incad.kramerius.rest.api.k5.client.impl; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.w3c.dom.Document; | ||
import org.w3c.dom.Element; | ||
|
||
import com.google.inject.Inject; | ||
|
||
import cz.incad.kramerius.SolrAccess; | ||
import cz.incad.kramerius.rest.api.k5.client.SolrMemoization; | ||
import cz.incad.kramerius.rest.api.k5.client.utils.PIDSupport; | ||
import cz.incad.kramerius.utils.XMLUtils; | ||
|
||
public class SolrMemoizationImpl implements SolrMemoization{ | ||
|
||
@Inject | ||
SolrAccess solrAccess; | ||
|
||
private Map<String, Element> elms = new HashMap<String, Element>(); | ||
|
||
@Override | ||
public void rememberIndexedDoc(String pid, Element elm) { | ||
this.elms.put(pid, elm); | ||
} | ||
|
||
@Override | ||
public Element getRememberedIndexedDoc(String pid) { | ||
return elms.get(pid); | ||
} | ||
|
||
@Override | ||
public synchronized Element askForIndexDocument(String pid) throws IOException { | ||
if (!this.elms.containsKey(pid)) { | ||
if (PIDSupport.isComposedPID(pid)) { | ||
pid = PIDSupport.convertToSOLRType(pid); | ||
} | ||
Document doc = solrAccess.getSolrDataDocument(pid); | ||
Element result = XMLUtils.findElement(doc.getDocumentElement(), "result"); | ||
if (result != null) { | ||
Element d = XMLUtils.findElement(result, "doc"); | ||
this.elms.put(pid, d); | ||
} | ||
} | ||
return this.elms.get(pid); | ||
} | ||
|
||
@Override | ||
public void clearMemo() { | ||
this.elms.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.