Add Triplestore and RDF query interface

Conflicts:
	build.xml
	defaults/yacy.init
	source/net/yacy/interaction/AugmentHtmlStream.java
pull/1/head
cominch 13 years ago committed by Michael Peter Christen
parent bc9a618e0a
commit 5d20cd324a

@ -51,5 +51,9 @@
<classpathentry kind="lib" path="lib/icu4j-core.jar"/>
<classpathentry kind="lib" path="lib/htmllexer.jar"/>
<classpathentry kind="lib" path="lib/htmlparser.jar"/>
<classpathentry kind="lib" path="lib/jena-2.6.4.jar"/>
<classpathentry kind="lib" path="lib/sax-2.0.1.jar"/>
<classpathentry kind="lib" path="lib/arq-2.8.7.jar"/>
<classpathentry kind="lib" path="lib/iri-0.8.jar"/>
<classpathentry kind="output" path="gen"/>
</classpath>

@ -40,6 +40,7 @@
<string>$JAVAROOT/lib/activation.jar</string>
<string>$JAVAROOT/lib/apache-mime4j-0.6.jar</string>
<string>$JAVAROOT/lib/apache-solr-solrj-3.6.0.jar</string>
<string>$JAVAROOT/lib/arq-2.8.7.jar</string>
<string>$JAVAROOT/lib/bcmail-jdk15-145.jar</string>
<string>$JAVAROOT/lib/bcprov-jdk15-145.jar</string>
<string>$JAVAROOT/lib/commons-codec-1.6.jar</string>
@ -56,11 +57,13 @@
<string>$JAVAROOT/lib/httpcore-4.2.jar</string>
<string>$JAVAROOT/lib/httpmime-4.2.jar</string>
<string>$JAVAROOT/lib/icu4j-core.jar</string>
<string>$JAVAROOT/lib/iri-0.8.jar</string>
<string>$JAVAROOT/lib/J7Zip-modified.jar</string>
<string>$JAVAROOT/lib/jakarta-oro-2.0.8.jar</string>
<string>$JAVAROOT/lib/jcifs-1.3.15.jar</string>
<string>$JAVAROOT/lib/jcl-over-slf4j-1.6.1.jar</string>
<string>$JAVAROOT/lib/jempbox-1.6.0.jar</string>
<string>$JAVAROOT/lib/jena-2.6.4.jar</string>
<string>$JAVAROOT/lib/jsch-0.1.42.jar</string>
<string>$JAVAROOT/lib/json-simple-1.1.jar</string>
<string>$JAVAROOT/lib/log4j-1.2.16.jar</string>
@ -69,6 +72,7 @@
<string>$JAVAROOT/lib/pdfbox-1.6.0.jar</string>
<string>$JAVAROOT/lib/poi-3.6-20091214.jar</string>
<string>$JAVAROOT/lib/poi-scratchpad-3.6-20091214.jar</string>
<string>$JAVAROOT/lib/sax-2.0.1.jar</string>
<string>$JAVAROOT/lib/servlet-api.jar</string>
<string>$JAVAROOT/lib/slf4j-api-1.6.1.jar</string>
<string>$JAVAROOT/lib/slf4j-jdk14-1.6.1.jar</string>

@ -158,6 +158,7 @@
<pathelement location="${lib}/activation.jar" />
<pathelement location="${lib}/apache-mime4j-0.6.jar" />
<pathelement location="${lib}/apache-solr-solrj-3.6.0.jar" />
<pathelement location="${lib}/arq-2.8.7.jar" />
<pathelement location="${lib}/bcmail-jdk15-145.jar" />
<pathelement location="${lib}/bcprov-jdk15-145.jar" />
<pathelement location="${lib}/commons-codec-1.6.jar" />
@ -174,11 +175,13 @@
<pathelement location="${lib}/httpcore-4.2.jar" />
<pathelement location="${lib}/httpmime-4.2.jar" />
<pathelement location="${lib}/icu4j-core.jar" />
<pathelement location="${lib}/iri-0.8.jar" />
<pathelement location="${lib}/J7Zip-modified.jar" />
<pathelement location="${lib}/jakarta-oro-2.0.8.jar" />
<pathelement location="${lib}/jcifs-1.3.15.jar" />
<pathelement location="${lib}/jcl-over-slf4j-1.6.1.jar" />
<pathelement location="${lib}/jempbox-1.6.0" />
<pathelement location="${lib}/jena-2.6.4.jar" />
<pathelement location="${lib}/jsch-0.1.42.jar" />
<pathelement location="${lib}/json-simple-1.1.jar" />
<pathelement location="${lib}/log4j-1.2.16.jar" />
@ -187,6 +190,7 @@
<pathelement location="${lib}/pdfbox-1.6.0.jar" />
<pathelement location="${lib}/poi-3.6-20091214.jar" />
<pathelement location="${lib}/poi-scratchpad-3.6-20091214.jar" />
<pathelement location="${lib}/sax-2.0.1.jar" />
<pathelement location="${lib}/servlet-api.jar" />
<pathelement location="${lib}/slf4j-api-1.6.1.jar" />
<pathelement location="${lib}/slf4j-jdk14-1.6.1.jar" />
@ -246,6 +250,8 @@
<path id="project.class.path">
<pathelement location="${build}" />
<pathelement location="${htroot}" />
<pathelement location="${lib}/arq-2.8.7.jar" />
<pathelement location="${lib}/jena-2.6.4.jar" />
</path>
<!-- compile htroot, htroot/yacy and htroot/htdocsdefault -->

@ -1050,4 +1050,38 @@ federated.service.yacy.indexing.enabled = true
federated.service.solr.indexing.enabled = false
federated.service.solr.indexing.url = http://127.0.0.1:8983/solr
federated.service.solr.indexing.sharding = MODULO_HOST_MD5
federated.service.solr.indexing.schemefile = solr.keys.default.list
federated.service.solr.indexing.schemefile = solr.keys.default.list
# RDF triplestore settings
triplestore.persistent = false
# Augmentation settings
parserAugmentation = true
proxyAugmentation = false
augmentation.reflect = false
augmentation.addDoctype = false
augmentation.reparse = false
# Interaction settings
interaction.feedback.enabled = true
interaction.feedback.url =
interaction.feedback.accept = false
interaction.usertracking.enabled = true
interaction.addcontent.enabled = false
interaction.userlogon.enabled = false
interaction.approvelist.enabled = false
interaction.suggestrejected.enabled = false
interaction.overlayinteraction.enabled = false
interaction.globalmenu.enabled = true
interaction.portalconfigbutton.enabled = true
interaction.crawltraces.enabled = false
interaction.userselfregistration.enabled = false
interaction.forcebookmarkimport =
interaction.visiblecategories = all
interaction.dontimportbookmarks =
interaction.autocrawler.enabled = false
interaction.autocrawler.domainfilter = .*
interaction.autocrawler.categoryfilter = .*

@ -0,0 +1,119 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>YaCy '#[clientname]#': Triplestore</title>
#%env/templates/metas.template%#
#%env/templates/jqueryheader.template%#
</head>
<body id="Experiments">
#%env/templates/header.template%#
#(mode)#
<div class="AddSection">
<script type="text/javascript">
function xyz() {
$.getJSON('yacysearch.json?query=rdfdatasource&Enter=Search&verify=never&contentdom=text&nav=hosts%2Cauthors%2Cnamespace%2Ctopics%2Cfiletype%2Cprotocol&startRecord=0&indexof=off&meanCount=5&resource=global&urlmaskfilter=.*&prefermaskfilter=&maximumRecords=10', null, function(data) {
$('#rdffileslist').val(data.channels[0].items[0].urlname);
});
}
</script>
<h2>Search RDF</h2>
<form action="Triple_p.html" method="post" enctype="multipart/form-data">
<input id="rdfsearch" name="rdfsearch" type="text" size="50" value="rdfdatasource" />
<input type="submit" value="Search" onclick="xyz(); return false;"/>
<br/>
<textarea id="rdffileslist" name="rdffileslist" cols="100" rows="10">
</textarea>
<input type="submit" value="Import Triples" />
</form>
</div>
<div class="AddSection">
<h2>or import RDF from local filesystem</h2>
<form action="Triple_p.html" method="post" enctype="multipart/form-data">
<input name="rdffile" type="file" size="50" maxlength="10000000" />
<input type="submit" value="Add Triples" />
</form>
</div>
<div class="AddSection">
<h2>Query</h2>
<form action="Triple_p.html" method="post" enctype="multipart/form-data">
<textarea name="query" cols="100" rows="10">
#[query]#
</textarea>
<input type="submit" value="Query" />
</form>
</div>
<br></br>
<!-- 0: viewing -->
#{entries}#
<div class="Experiment">
<a href="./experiments/#[link]#/" target="_blank"><h2 class="PostSubject">#[subject]#</h2></a>
<p class="PostInfo">
<a href="/Crawler_p.html?createBookmark=off&xsstopw=off&crawlingDomMaxPages=10000&intention=&range=subpath&indexMedia=on&xdstopw=off&storeHTCache=off&sitemapURL=&repeat_time=1&cachePolicy=never&indexText=on&crawlingMode=url&crawlingURL=#[publiclink]#&bookmarkTitle=&mustnotmatch=&crawlingDomFilterDepth=1&crawlingDomFilterCheck=off&crawlingstart=Start%20New%20Crawl&xpstopw=off&crawlingDepth=0" target="_blank">Publish</a> |
<a href="/Crawler_p.html?createBookmark=off&xsstopw=off&crawlingDomMaxPages=10000&intention=&range=subpath&indexMedia=on&xdstopw=off&storeHTCache=off&sitemapURL=&repeat_time=1&cachePolicy=never&indexText=on&crawlingMode=url&crawlingURL=#[publiclink_ip]#&bookmarkTitle=&mustnotmatch=&crawlingDomFilterDepth=1&crawlingDomFilterCheck=off&crawlingstart=Start%20New%20Crawl&xpstopw=off&crawlingDepth=0" target="_blank">Publish using IP-Adress</a>
| <a href="UnpublishExperiment_p.html?experiment=#[subject]#&urlstring=#[publiclink]#">Unpublish and remove</a> | <a href="#[publiclinkproxy]#">Preview via inbuilt proxy</a>
</p>
</div>
#{/entries}#
<!-- <applet
code="org.openscience.jchempaint.applet.JChemPaintEditorApplet"
archive="/applets/jchempaint-applet-core.jar"
name="Editor"
width="600" height="500">
<param name="load" value="a-pinene.mol">
</applet> -->
<div class="AddSection">
<h2>Result</h2>
#[rdfdump]#
<br/>
<br/>
#{output}##[caption]#
#{/output}#
</div>
::
<!-- 3: Access Denied (no rights) -->
<h3>Access denied</h3>
<p>To edit or create experiment entries you need to be logged in as Administrator.</p>
#(/mode)#
#%env/templates/footer.template%#
</body>
</html>

@ -0,0 +1,135 @@
import java.io.ByteArrayOutputStream;
import java.net.MalformedURLException;
import java.util.List;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.interaction.TripleStore;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.search.Switchboard;
import de.anomic.http.server.HTTPDemon;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory ;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.sparql.algebra.Algebra ;
import com.hp.hpl.jena.sparql.algebra.Op ;
import com.hp.hpl.jena.sparql.engine.QueryIterator ;
import com.hp.hpl.jena.sparql.engine.binding.Binding ;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.util.FileManager;
public class Triple_p {
public static serverObjects respond(final RequestHeader header,
final serverObjects post, final serverSwitch env) {
final Switchboard sb = (Switchboard) env;
final serverObjects prop = new serverObjects();
boolean hasRights = sb.verifyAuthentication(header);
prop.put("display", 1); // Fixed to 1
prop.putHTML("mode_output", "no query performed");
String q = "PREFIX lln: <http://virtual.liebel-lab.org/n#>\n"+
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"+
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n"+
"SELECT ?resource ?pa\n"+
"WHERE {\n"+
"?resource lln:percentageofarea ?pa .\n"+
"FILTER (xsd:float (?pa) > 3.000)\n"+
"}";
if (post != null) {
if (post.containsKey("submit")) {
//
System.out.println (post.get("submit"));
}
if (post.containsKey("rdffileslist")) {
String list = post.get("rdffileslist");
for (String s: list.split("\n")) {
String newurl = s;
try {
DigestURI d = new DigestURI (s);
if (d.getHost().endsWith(".yacy")) {
newurl = d.getProtocol()+"://"+HTTPDemon.getAlternativeResolver().resolve(d.getHost())+d.getPath();
System.out.println (newurl);
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TripleStore.Load (newurl);
}
}
if (post.containsKey("rdffile")) {
TripleStore.Add(post.get("rdffile$file"));
}
if (post.containsKey("query")) {
// Create a new query
String queryString = post.get("query");
q = queryString;
int count = 0;
try {
com.hp.hpl.jena.query.Query query = QueryFactory.create(queryString);
// Execute the query and obtain results
QueryExecution qe = QueryExecutionFactory.create(query, TripleStore.model);
ResultSet resultSet = qe.execSelect();
ByteArrayOutputStream sos = new ByteArrayOutputStream();
ResultSetFormatter.outputAsRDF(sos, "", resultSet);
prop.putHTML("mode_rdfdump", sos.toString());
for (String s: resultSet.getResultVars()) {
prop.putHTML("mode_output_"+count+"_caption", s);
count ++;
}
} catch (Exception e) {
prop.putHTML("mode_rdfdump", "error");
}
prop.putHTML("mode_output", ""+count);
}
}
prop.putHTML("mode_query", q);
// return rewrite properties
return prop;
}
}

@ -47,15 +47,15 @@ border-bottom: 1px solid #ffffff;
</style>
<div id="sidebar-source" class="sci_panel" style="">
<div id="sidebar-source" class="sci_panel" style="top: 20px;">
source <img src="/currentyacypeer/env/grafics/bad.png" onclick="contribution (document.location.href, 'like source', '#[username]#'); return false">
<!--#include virtual="/interaction/Scibutton_part.html?details=true&amp;url=#[link]#" -->
</div>
<div id="sidebar-document" style="display: none;">
<div id="sidebar-document" class="sci_panel" style="top: 70px;">
document
document <img src="/currentyacypeer/env/grafics/bad.png" onclick="contribution (document.location.href, 'like source', '#[username]#'); return false">
</div>

@ -50,6 +50,8 @@ public class OverlayInteraction {
UserDB.Entry entry=null;
prop.put("enabled_username", "anonymous");
prop.put("enabled_link", post.get("link", ""));
//identified via HTTPPassword
entry=sb.userDB.proxyAuth((header.get(RequestHeader.AUTHORIZATION, "xxxxxx")));

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -386,7 +386,7 @@ public class AugmentHtmlStream {
bodychildren.add(new org.htmlparser.nodes.TextNode(loadInternal("interaction/Footer.html", requestHeader)));
bodychildren.add(new org.htmlparser.nodes.TextNode(loadInternal("interaction/OverlayInteraction.html", requestHeader)));
bodychildren.add(new org.htmlparser.nodes.TextNode(loadInternal("interaction/OverlayInteraction.html?link="+url.toNormalform(true, false), requestHeader)));
// ADD AUGMENTED INFO

Loading…
Cancel
Save