persistency for vocabulary facet switch

pull/1/head
Michael Peter Christen 10 years ago
parent efbc9a3561
commit a8a2b7a803

@ -107,8 +107,6 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
<dl>
<dt>Vocabulary Name</dt>
<dd><input type="text" name="discovername" value="" size="78" maxlength="128" onkeydown="for (i=0; i < 6; i++) document.getElementsByName('discovermethod')[i].disabled=''"/></dd>
<dt></dt>
<dd><input type="checkbox" name="isFacet" checked="checked"/> this shall be a search facet (disable this for large vocabularies!)</dd>
<hr>
<dt>Empty Vocabulary&nbsp;<input type="radio" name="discovermethod" value="none" checked="checked" disabled="disabled"/></dt>
<dd></dd>

@ -74,7 +74,6 @@ public class Vocabulary_p {
if (discoveruri == null) discoverobjectspace = "";
Map<String, Tagging.SOTuple> table = new LinkedHashMap<String, Tagging.SOTuple>();
File propFile = LibraryProvider.autotagging.getVocabularyFile(discovername);
final boolean isFacet = post.getBoolean("isFacet");
final boolean discoverNot = post.get("discovermethod", "").equals("none");
final boolean discoverFromPath = post.get("discovermethod", "").equals("path");
final boolean discoverFromTitle = post.get("discovermethod", "").equals("title");
@ -185,7 +184,6 @@ public class Vocabulary_p {
}
}
Tagging newvoc = new Tagging(discovername, propFile, discoverobjectspace, table);
newvoc.setFacet(isFacet);
LibraryProvider.autotagging.addVocabulary(newvoc);
vocabularyName = discovername;
vocabulary = newvoc;
@ -234,7 +232,11 @@ public class Vocabulary_p {
// check the isFacet property
if (vocabulary != null && post.containsKey("set")) {
vocabulary.setFacet(post.getBoolean("isFacet"));
boolean isFacet = post.getBoolean("isFacet");
vocabulary.setFacet(isFacet);
Set<String> omit = env.getConfigSet("search.result.show.vocabulary.omit");
if (isFacet) omit.remove(vocabularyName); else omit.add(vocabularyName);
env.setConfig("search.result.show.vocabulary.omit", omit);
}
}
} catch (final IOException e) {

@ -278,8 +278,6 @@ public class Tagging {
public void setFacet(boolean isFacet) {
this.isFacet = isFacet;
String omit = Switchboard.getSwitchboard().getConfig("search.result.show.vocabulary.omit", "");
}
public int size() {

@ -101,6 +101,7 @@ import net.yacy.cora.federate.solr.connector.ShardSelection;
import net.yacy.cora.federate.solr.connector.SolrConnector.LoadTimeURL;
import net.yacy.cora.federate.solr.instance.RemoteInstance;
import net.yacy.cora.federate.yacy.CacheStrategy;
import net.yacy.cora.lod.vocabulary.Tagging;
import net.yacy.cora.order.Base64Order;
import net.yacy.cora.order.Digest;
import net.yacy.cora.order.NaturalOrder;
@ -385,6 +386,12 @@ public final class Switchboard extends serverSwitch {
public void run() {
Thread.currentThread().setName("LibraryProvider.initialize");
LibraryProvider.initialize(Switchboard.this.dictionariesPath);
// persistent Vocabulary Switch
Set<String> omit = Switchboard.this.getConfigSet("search.result.show.vocabulary.omit");
for (String o: omit) {
Tagging t = LibraryProvider.autotagging.getVocabulary(o);
if (t != null) t.setFacet(false);
}
}
}.start();

@ -282,6 +282,19 @@ public class serverSwitch {
}
}
public void setConfig(final String key, final String[] value) {
StringBuilder sb = new StringBuilder();
if (value != null) for (String s: value) sb.append(',').append(s);
setConfig(key, sb.length() > 0 ? sb.substring(1) : "");
}
public void setConfig(final String key, Set<String> value) {
String[] a = new String[value.size()];
int c = 0;
for (String s: value) a[c++] = s;
setConfig(key, a);
}
public void removeConfig(final String key) {
this.configProps.remove(key);
}
@ -410,6 +423,18 @@ public class serverSwitch {
return CommonPattern.COMMA.split(this.getConfig(key, dflt));
}
/**
* get a configuration parameter set
* @param key
* @param dflt a default list
* @return a set of strings which had been separated by comma in the setting
*/
public Set<String> getConfigSet(final String key) {
Set<String> h = new LinkedHashSet<>();
for (String s: getConfigArray(key, "")) {s = s.trim(); if (s.length() > 0) h.add(s.trim());}
return h;
}
/**
* Create a File instance for a configuration setting specifying a path.
*

Loading…
Cancel
Save