create new vocabularies also without an objectspace. this creates an

empty vocabulary
pull/1/head
Michael Peter Christen 13 years ago
parent a5cdfb91de
commit 1f9120d189

@ -4,7 +4,7 @@
<title>YaCy '#[clientname]#': Federated Index</title> <title>YaCy '#[clientname]#': Federated Index</title>
#%env/templates/metas.template%# #%env/templates/metas.template%#
</head> </head>
<body id="Vocabulary_p"> <body id="Vocabulary_p" onload="document.getElementById('newterm').focus()">
#%env/templates/header.template%# #%env/templates/header.template%#
#%env/templates/submenuSemantic.template%# #%env/templates/submenuSemantic.template%#
<h2>Vocabulary Administration</h2> <h2>Vocabulary Administration</h2>
@ -75,15 +75,15 @@
<td align="center">#(editable)#&nbsp;::<input type="checkbox" name="modify_#[term]#" id="modify_#[term]#" value="checked" disabled="disabled"/>#(/editable)#</td> <td align="center">#(editable)#&nbsp;::<input type="checkbox" name="modify_#[term]#" id="modify_#[term]#" value="checked" disabled="disabled"/>#(/editable)#</td>
<td align="center">#(editable)#&nbsp;::<input type="checkbox" name="delete_#[term]#" id="delete_#[term]#" value="checked" onchange="this.form.submit()"/>#(/editable)#</td> <td align="center">#(editable)#&nbsp;::<input type="checkbox" name="delete_#[term]#" id="delete_#[term]#" value="checked" onchange="this.form.submit()"/>#(/editable)#</td>
<td align="left">#[term]#</td> <td align="left">#[term]#</td>
<td align="left">#(editable)##[synonyms]#::<input type="text" name="synonyms_#[term]#" value="#[synonyms]#" size="60" maxlength="1024" onclick="document.getElementById('modify_#[term]#').checked='checked'; document.getElementById('modify_#[term]#').disabled=''"/>#(/editable)#</td> <td align="left">#(editable)##[synonyms]#::<input type="text" name="synonyms_#[term]#" value="#[synonyms]#" size="40" maxlength="1024" onkeyup="document.getElementById('modify_#[term]#').checked='checked'; document.getElementById('modify_#[term]#').disabled=''"/>#(/editable)#</td>
<td align="left">#(editable)##[objectlink]#::<input type="text" name="objectlink_#[term]#" value="#[objectlink]#" size="60" maxlength="1024" onclick="document.getElementById('modify_#[term]#').checked='checked'; document.getElementById('modify_#[term]#').disabled=''"/>#(/editable)#</td> <td align="left">#(editable)##[objectlink]#::<input type="text" name="objectlink_#[term]#" value="#[objectlink]#" size="60" maxlength="1024" onkeyup="document.getElementById('modify_#[term]#').checked='checked'; document.getElementById('modify_#[term]#').disabled=''"/>#(/editable)#</td>
</tr> </tr>
#{/terms}# #{/terms}#
#(editable)#:: #(editable)#::
<tr class="TableCellDark"> <tr class="TableCellDark">
<td align="center" colspan="2"><input type="checkbox" name="add_new" id="add_new" value="checked" disabled="disabled"/><i>add</i></td> <td align="center" colspan="2"><input type="checkbox" name="add_new" id="add_new" value="checked" disabled="disabled"/><i>add</i></td>
<td align="left"><input type="text" name="newterm" id="newterm" value="" size="24" maxlength="128" onclick="document.getElementById('add_new').checked='checked'; document.getElementById('add_new').disabled=''"/></td> <td align="left"><input type="text" name="newterm" id="newterm" value="" size="24" maxlength="128" onkeyup="document.getElementById('add_new').checked='checked'; document.getElementById('add_new').disabled=''"/></td>
<td align="left"><input type="text" name="newsynonyms" id="newsynonyms" value="" size="60" maxlength="1024"/></td> <td align="left"><input type="text" name="newsynonyms" id="newsynonyms" value="" size="40" maxlength="1024"/></td>
<td align="left"><input type="text" name="newobjectlink" id="newobjectlink" value="" size="60" maxlength="1024"/></td> <td align="left"><input type="text" name="newobjectlink" id="newobjectlink" value="" size="60" maxlength="1024"/></td>
</tr> </tr>
<tr class="TableCellDark"> <tr class="TableCellDark">

@ -65,15 +65,17 @@ public class Vocabulary_p {
if (vocabulary == null) { if (vocabulary == null) {
// create a vocabulary // create a vocabulary
String discovername = post.get("discovername", ""); String discovername = post.get("discovername", "");
if (discovername.length() > 0) {
String discoverobjectspace = post.get("discoverobjectspace", ""); String discoverobjectspace = post.get("discoverobjectspace", "");
MultiProtocolURI discoveruri = null; MultiProtocolURI discoveruri = null;
if (discoverobjectspace.length() > 0) try {discoveruri = new MultiProtocolURI(discoverobjectspace);} catch (MalformedURLException e) {} if (discoverobjectspace.length() > 0) try {discoveruri = new MultiProtocolURI(discoverobjectspace);} catch (MalformedURLException e) {}
if (discovername.length() > 0 && discoveruri != null) { if (discoveruri == null) discoverobjectspace = "";
Map<String, Tagging.SOTuple> table = new TreeMap<String, Tagging.SOTuple>();
File propFile = LibraryProvider.autotagging.getVocabularyFile(discovername);
if (discoveruri != null) {
String segmentName = sb.getConfig(SwitchboardConstants.SEGMENT_PUBLIC, "default"); String segmentName = sb.getConfig(SwitchboardConstants.SEGMENT_PUBLIC, "default");
Segment segment = sb.indexSegments.segment(segmentName); Segment segment = sb.indexSegments.segment(segmentName);
Iterator<DigestURI> ui = segment.urlSelector(discoveruri); Iterator<DigestURI> ui = segment.urlSelector(discoveruri);
Map<String, Tagging.SOTuple> table = new TreeMap<String, Tagging.SOTuple>();
File propFile = LibraryProvider.autotagging.getVocabularyFile(discovername);
while (ui.hasNext()) { while (ui.hasNext()) {
DigestURI u = ui.next(); DigestURI u = ui.next();
String u0 = u.toNormalform(true, false); String u0 = u.toNormalform(true, false);
@ -87,12 +89,12 @@ public class Vocabulary_p {
if (t.length() == 0) continue; if (t.length() == 0) continue;
table.put(t, new Tagging.SOTuple("", u0)); table.put(t, new Tagging.SOTuple("", u0));
} }
if (table.size() > 0) { }
Tagging newvoc = new Tagging(discovername, propFile, discoverobjectspace, table); Tagging newvoc = new Tagging(discovername, propFile, discoverobjectspace, table);
LibraryProvider.autotagging.addVocabulary(newvoc); LibraryProvider.autotagging.addVocabulary(newvoc);
vocabularyName = discovername;
vocabulary = newvoc; vocabulary = newvoc;
} }
}
} else { } else {
// check if objectspace was set // check if objectspace was set
vocabulary.setObjectspace(post.get("objectspace", vocabulary.getObjectspace() == null ? "" : vocabulary.getObjectspace())); vocabulary.setObjectspace(post.get("objectspace", vocabulary.getObjectspace() == null ? "" : vocabulary.getObjectspace()));
@ -133,6 +135,7 @@ public class Vocabulary_p {
if (vocabulary != null && post.get("delete_vocabulary", "").equals("checked") ) { if (vocabulary != null && post.get("delete_vocabulary", "").equals("checked") ) {
LibraryProvider.autotagging.deleteVocabulary(vocabularyName); LibraryProvider.autotagging.deleteVocabulary(vocabularyName);
vocabulary = null; vocabulary = null;
vocabularyName = null;
} }
} }
} catch (IOException e) { } catch (IOException e) {

Loading…
Cancel
Save