show triplestore metadata in yacydoc and viewfile

pull/1/head
Michael Peter Christen 13 years ago
parent 0fbd749207
commit 64c0268b2b

@ -42,6 +42,7 @@
<dt>Description:</dt><dd>#[desc]#</dd>
<dt>Size:</dt> <dd>#[size]# Bytes</dd>#(mimeTypeAvailable)#::
<dt>MimeType:</dt> <dd>#[mimeType]#</dd>#(/mimeTypeAvailable)#
<dt>Triplestore:</dt><dd><pre>#[triples]#</pre></dd>
<dt><label for="viewMode">View as</label>:</dt>
<dd>
<select id="viewMode" name="viewMode" onchange='this.form.submit()'>

@ -39,6 +39,7 @@ import java.util.Properties;
import net.yacy.cora.document.ASCII;
import net.yacy.cora.document.MultiProtocolURI;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.lod.JenaTripleStore;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.services.federated.yacy.CacheStrategy;
import net.yacy.document.Condenser;
@ -343,6 +344,7 @@ public class ViewFile {
prop.putNum("error_size", size);
prop.put("error_mimeTypeAvailable", (response.getMimeType() == null) ? "0" : "1");
prop.put("error_mimeTypeAvailable_mimeType", response.getMimeType());
prop.putXML("error_triples", JenaTripleStore.getMetadataByURLHash(url.hash()));
return prop;
}

@ -12,6 +12,12 @@ you can validate it with http://validator.w3.org/
<head profile="http://www.w3.org/2003/g/data-view">
<link rel="transformation" href="http://www-sop.inria.fr/acacia/soft/RDFa2RDFXML.xsl"/>
<div id="api">
<a href="yacydoc.xml"><img src="env/grafics/api.png" width="60" height="40" alt="API" /></a>
<span>This search result can also be retrieved as XML.
Click the API icon to see an example call to the search rss API.
To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de/wiki/index.php/Dev:API">API wiki page</a>.</span>
</div>
#%env/templates/metas.template%#
<title>#[dc_title]#</title>
</head>
@ -45,6 +51,7 @@ you can validate it with http://validator.w3.org/
<dt>Incoming Links (citation)</dt><dd property="yacy:citations">#[yacy_citations]#</dd>
<dt>Location</dt><dd><a href="/osm.png?lon=#[geo_long]#&lat=#[geo_lat]#&zoom=14" onclick="return hs.expand(this)">lat=#[geo_lat]#, lon=#[geo_long]#</a></dd>
<dt>Metadata Triplestore</dt><dd><pre>#[triples]#</pre></dd>
</dl>
</fieldset>

@ -25,11 +25,24 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import java.io.ByteArrayOutputStream;
import java.net.MalformedURLException;
import java.util.Iterator;
import java.util.Map;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import net.yacy.cora.date.ISO8601Formatter;
import net.yacy.cora.document.ASCII;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.lod.JenaTripleStore;
import net.yacy.cora.lod.vocabulary.Tagging;
import net.yacy.cora.lod.vocabulary.YaCyMetadata;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.sorting.ConcurrentScoreMap;
import net.yacy.cora.sorting.ScoreMap;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.data.meta.URIMetadataRow;
import net.yacy.kelondro.data.word.Word;
@ -71,9 +84,9 @@ public class yacydoc {
prop.put("geo_long", "");
prop.put("yacy_urlhash", "");
prop.putXML("yacy_loaddate", "");
prop.putXML("yacy_referrer_hash", "");
prop.putXML("yacy_referrer_url", "");
prop.put("yacy_loaddate", "");
prop.put("yacy_referrer_hash", "");
prop.put("yacy_referrer_url", "");
prop.put("yacy_size", "");
prop.put("yacy_words", "");
prop.put("yacy_citations", "");
@ -126,6 +139,9 @@ public class yacydoc {
prop.put("yacy_citations", sb.indexSegments.segment(Segments.Process.PUBLIC).urlCitation().count(entry.hash()));
prop.put("yacy_inbound", entry.llocal());
prop.put("yacy_outbound", entry.lother());
// extract the submodel from the triplestore
prop.putXML("triples", JenaTripleStore.getMetadataByURLHash(entry.hash()));
// return rewrite properties
return prop;

@ -33,6 +33,5 @@ you can validate it with http://www.stg.brown.edu/service/xmlvalid/
<yacy:inbound>#[yacy_inbound]#</yacy:inbound>
<yacy:outbound>#[yacy_outbound]#</yacy:outbound>
<yacy:citations>#[yacy_citations]#</yacy:citations>
</record>
</metadata>

@ -3,6 +3,7 @@
package net.yacy.cora.lod;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@ -26,6 +27,8 @@ import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.ResIterator;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Selector;
import com.hp.hpl.jena.rdf.model.SimpleSelector;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.util.FileManager;
@ -236,6 +239,22 @@ public class JenaTripleStore {
};
}
public static Model getSubmodelBySubject(String subject) {
Selector q = new SimpleSelector(model.getResource(subject), (Property) null, (RDFNode) null);
final Model m = model.query(q);
m.setNsPrefix(Tagging.DEFAULT_PREFIX, Tagging.DEFAULT_NAMESPACE);
m.setNsPrefix(DCTerms.PREFIX, DCTerms.NAMESPACE);
return m;
}
public static String getMetadataByURLHash(byte[] urlhash) {
String subject = YaCyMetadata.hashURI(urlhash);
Model model = JenaTripleStore.getSubmodelBySubject(subject);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
model.write(baos, "RDF/XML-ABBREV");
return UTF8.String(baos.toByteArray());
}
public static void initPrivateStores() {
Switchboard switchboard = Switchboard.getSwitchboard();

@ -91,7 +91,7 @@ public class Autotagging {
public void deleteVocabulary(String name) {
Tagging v = this.vocabularies.remove(name);
if (v == null) return;
if (v == null || v.getFile() == null) return;
v.getFile().delete();
}

@ -285,7 +285,6 @@ public final class RWIProcess extends Thread
|| pattern.equals("smb://.*")
|| pattern.equals("file://.*");
long remaining;
int count = 0;
pollloop: while ( true ) {
remaining = timeout - System.currentTimeMillis();
if (remaining <= 0) {
@ -302,7 +301,6 @@ public final class RWIProcess extends Thread
}
assert (iEntry.urlhash().length == index.row().primaryKeyLength);
//if (iEntry.urlHash().length() != index.row().primaryKeyLength) continue;
count++;
// increase flag counts
for ( int j = 0; j < 32; j++ ) {
@ -623,7 +621,7 @@ public final class RWIProcess extends Thread
final long timeout = System.currentTimeMillis() + Math.max(10, waitingtime);
int p = -1;
long timeleft;
takeloop: while ( (timeleft = timeout - System.currentTimeMillis()) > 0 ) {
while ( (timeleft = timeout - System.currentTimeMillis()) > 0 ) {
//System.out.println("timeleft = " + timeleft);
final WeakPriorityBlockingQueue.Element<WordReferenceVars> obrwi = takeRWI(skipDoubleDom, timeleft);
if ( obrwi == null ) {

Loading…
Cancel
Save