Changed tabs to spaces.

Create luceneIndex directory in workspace's cache dir.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@1091 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-07-08 23:39:53 +00:00
parent 513283d4d1
commit c041a1966e
24 changed files with 1040 additions and 1037 deletions

View File

@ -12,5 +12,6 @@
<classpathentry kind="lib" path="module/MOD-INF/lib/lucene-core-3.0.1.jar"/>
<classpathentry kind="lib" path="module/MOD-INF/lib/xercesImpl-2.7.1.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/gridworks-server"/>
<classpathentry kind="lib" path="/gridworks/webapp/WEB-INF/lib/butterfly-trunk.jar" sourcepath="/gridworks/webapp/WEB-INF/lib-src/butterfly-trunk.jar"/>
<classpathentry kind="output" path="module/MOD-INF/classes"/>
</classpath>

View File

@ -21,7 +21,7 @@ public class DeleteVocabularyCommand extends Command{
throws ServletException, IOException {
String uri = request.getParameter("uri");
try {
VocabularyManager.singleton.deleteVocabulary(uri);
VocabularyManager.getSingleton(servlet).deleteVocabulary(uri);
respondJSON(response, new Jsonizable() {
@Override

View File

@ -24,7 +24,7 @@ public class ImportVocabularyCommand extends Command{
String url = request.getParameter("url");
String namespace = request.getParameter("namespace");
try {
VocabularyManager.singleton.addVocabulary(url, prefix, namespace);
VocabularyManager.getSingleton(servlet).addVocabulary(url, prefix, namespace);
respondJSON(response, new Jsonizable() {
@Override

View File

@ -25,7 +25,7 @@ public class ListVocabulariesCommand extends Command{
writer.key("vocabularies");
writer.array();
Properties p = new Properties();
for(Vocabulary v:VocabularyManager.singleton.getVocabularies()){
for(Vocabulary v:VocabularyManager.getSingleton(servlet).getVocabularies()){
v.write(writer, p);
}
writer.endArray();

View File

@ -40,9 +40,9 @@ public class SuggestTermCommand extends Command{
writer.array();
List<RDFNode> nodes;
if(type!=null && type.trim().equals("property")){
nodes = VocabularyManager.singleton.searchProperties(prefix);
nodes = VocabularyManager.getSingleton(servlet).searchProperties(prefix);
}else{
nodes = VocabularyManager.singleton.searchClasses(prefix);
nodes = VocabularyManager.getSingleton(servlet).searchClasses(prefix);
}
for(RDFNode c:nodes){
c.writeAsSearchResult(writer);

View File

@ -21,13 +21,14 @@ import org.apache.lucene.store.Directory;
import org.apache.lucene.store.SimpleFSDirectory;
import org.apache.lucene.util.Version;
import com.metaweb.gridworks.GridworksServlet;
/**
* @author fadmaa
*
*/
public class VocabularyManager {
private static final String INDEX_PATH = "luceneIndex";
private static final String CLASS_TYPE = "class";
private static final String PROPERTY_TYPE = "property";
private static final String VOCABULARY_TYPE = "vocabulary";
@ -37,18 +38,19 @@ public class VocabularyManager {
private Directory _directory;
public static VocabularyManager singleton;
private static VocabularyManager singleton;
private List<Vocabulary> vocabularies = new ArrayList<Vocabulary>();
static{
singleton = new VocabularyManager();
static public VocabularyManager getSingleton(GridworksServlet servlet) {
return singleton != null ? singleton : (singleton = new VocabularyManager(servlet));
}
private VocabularyManager(){
private VocabularyManager(GridworksServlet servlet) {
try{
synchronized (this) {
_directory = new SimpleFSDirectory(new File(INDEX_PATH));
File dir = servlet.getCacheDir("rdfImporter");
_directory = new SimpleFSDirectory(new File(dir, "luceneIndex"));
writer = new IndexWriter(_directory, new StandardAnalyzer(Version.LUCENE_30), true, IndexWriter.MaxFieldLength.LIMITED);
searcher = new IndexSearcher(_directory);
updateVocabulariesList();