From 1f9120d18980bc967a59f8bca7fe0d80d42c33b2 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Fri, 15 Jun 2012 02:43:55 +0200 Subject: [PATCH] create new vocabularies also without an objectspace. this creates an empty vocabulary --- htroot/Vocabulary_p.html | 10 ++++---- htroot/Vocabulary_p.java | 51 +++++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/htroot/Vocabulary_p.html b/htroot/Vocabulary_p.html index c3bbac0e9..7a2fe2bf4 100644 --- a/htroot/Vocabulary_p.html +++ b/htroot/Vocabulary_p.html @@ -4,7 +4,7 @@ YaCy '#[clientname]#': Federated Index #%env/templates/metas.template%# - + #%env/templates/header.template%# #%env/templates/submenuSemantic.template%#

Vocabulary Administration

@@ -75,15 +75,15 @@ #(editable)# ::#(/editable)# #(editable)# ::#(/editable)# #[term]# - #(editable)##[synonyms]#::#(/editable)# - #(editable)##[objectlink]#::#(/editable)# + #(editable)##[synonyms]#::#(/editable)# + #(editable)##[objectlink]#::#(/editable)# #{/terms}# #(editable)#:: add - - + + diff --git a/htroot/Vocabulary_p.java b/htroot/Vocabulary_p.java index 2cef2b425..656992967 100644 --- a/htroot/Vocabulary_p.java +++ b/htroot/Vocabulary_p.java @@ -65,33 +65,35 @@ public class Vocabulary_p { if (vocabulary == null) { // create a vocabulary String discovername = post.get("discovername", ""); - String discoverobjectspace = post.get("discoverobjectspace", ""); - MultiProtocolURI discoveruri = null; - if (discoverobjectspace.length() > 0) try {discoveruri = new MultiProtocolURI(discoverobjectspace);} catch (MalformedURLException e) {} - if (discovername.length() > 0 && discoveruri != null) { - String segmentName = sb.getConfig(SwitchboardConstants.SEGMENT_PUBLIC, "default"); - Segment segment = sb.indexSegments.segment(segmentName); - Iterator ui = segment.urlSelector(discoveruri); + if (discovername.length() > 0) { + String discoverobjectspace = post.get("discoverobjectspace", ""); + MultiProtocolURI discoveruri = null; + if (discoverobjectspace.length() > 0) try {discoveruri = new MultiProtocolURI(discoverobjectspace);} catch (MalformedURLException e) {} + if (discoveruri == null) discoverobjectspace = ""; Map table = new TreeMap(); File propFile = LibraryProvider.autotagging.getVocabularyFile(discovername); - while (ui.hasNext()) { - DigestURI u = ui.next(); - String u0 = u.toNormalform(true, false); - String t = u0.substring(discoverobjectspace.length()); - if (t.indexOf('/') >= 0) continue; - int p = t.indexOf('.'); - if (p >= 0) t = t.substring(0, p); - while ((p = t.indexOf(':')) >= 0) t = t.substring(p + 1); - while ((p = t.indexOf('=')) >= 0) t = t.substring(p + 1); - if (p >= 0) t = t.substring(p + 1); - if (t.length() == 0) continue; - table.put(t, new Tagging.SOTuple("", u0)); - } - if (table.size() > 0) { - Tagging newvoc = new Tagging(discovername, propFile, discoverobjectspace, table); - LibraryProvider.autotagging.addVocabulary(newvoc); - vocabulary = newvoc; + if (discoveruri != null) { + String segmentName = sb.getConfig(SwitchboardConstants.SEGMENT_PUBLIC, "default"); + Segment segment = sb.indexSegments.segment(segmentName); + Iterator ui = segment.urlSelector(discoveruri); + while (ui.hasNext()) { + DigestURI u = ui.next(); + String u0 = u.toNormalform(true, false); + String t = u0.substring(discoverobjectspace.length()); + if (t.indexOf('/') >= 0) continue; + int p = t.indexOf('.'); + if (p >= 0) t = t.substring(0, p); + while ((p = t.indexOf(':')) >= 0) t = t.substring(p + 1); + while ((p = t.indexOf('=')) >= 0) t = t.substring(p + 1); + if (p >= 0) t = t.substring(p + 1); + if (t.length() == 0) continue; + table.put(t, new Tagging.SOTuple("", u0)); + } } + Tagging newvoc = new Tagging(discovername, propFile, discoverobjectspace, table); + LibraryProvider.autotagging.addVocabulary(newvoc); + vocabularyName = discovername; + vocabulary = newvoc; } } else { // check if objectspace was set @@ -133,6 +135,7 @@ public class Vocabulary_p { if (vocabulary != null && post.get("delete_vocabulary", "").equals("checked") ) { LibraryProvider.autotagging.deleteVocabulary(vocabularyName); vocabulary = null; + vocabularyName = null; } } } catch (IOException e) {