SimpleGraph-SMW
SimpleGraphModule
SimpleGraph SMW module
The SimpleGraph SMW module makes Semantic MediaWiki accessible via the SMW API see SemanticMedia Wiki API.
Sources
- System: SmwSystem.java
- JUnit-Test: TestSmwSystem.java
Example
With the SimpleGraph SMW module you can access Semantic MediaWiki query results and process them with Gremlin. Since this Webpage is based on SemanticMediaWiki we can use content from this wiki to explain the concepts. Let's eq.g. query the available SimpleGraph modules:
SimpleGraphModule | name | logo | modulename | systemname | url | apiname | apiurl | documentation |
---|---|---|---|---|---|---|---|---|
SimpleGraph-CalDAV | CalDAV | caldav | CaldavSystem | https://en.wikipedia.org/wiki/CalDAV | ical4j library for parsing and building iCalendar data models | https://github.com/ical4j/ical4j | makes Calendar data available via ical4j | |
SimpleGraph-CardDAV | CardDAV | carddav | CarddavSystem | https://en.wikipedia.org/wiki/CardDAV | makes VCard data available | |||
SimpleGraph-Excel | Excel | excel | ExcelSystem | https://en.wikipedia.org/wiki/Microsoft Excel | Apache POI XSSF/HSSF | https://poi.apache.org/components/spreadsheet/quick-guide.html | makes Microsoft Excel workbooks accessible via the Apache POI API | |
SimpleGraph-FileSystem | FileSystem | filesystem | FileSystem | https://en.wikipedia.org/wiki/File system | java.io.File | https://docs.oracle.com/javase/8/docs/api/java/io/File.html | makes your FileSystem accessible via the Java FileSystem API | |
SimpleGraph-GeoJSON | GeoJSON | geojson | GeoJsonSystem | https://en.wikipedia.org/wiki/GeoJSON | GeoJSON support for Google gson library | https://github.com/filosganga/geogson | makes GeoJSON data available | |
SimpleGraph-HTML | HTML | html | HtmlSystem | https://en.wikipedia.org/wiki/HTML | HTML Cleaner | http://htmlcleaner.sourceforge.net/ | makes HTML files accessible via HTML Cleaner parser | |
SimpleGraph-JSON | JSON | json | JsonSystem | https://en.wikipedia.org/wiki/JavaScript Object Notation | JSON | https://www.json.org/ | makes JSON parse results accessible to Graph processing. | |
SimpleGraph-Java | Java | java | JavaSystem | https://en.wikipedia.org/wiki/Java (programming language) | javaparser | https://github.com/javaparser/javaparser | makes Java code parse results accessible to Graph processing. | |
SimpleGraph-Mail | MailSystem | https://en.wikipedia.org/wiki/MIME | E-Mail access for rfc822 and MIME formatted Mailbox files (e.g. Thunderbird) | https://james.apache.org/mime4j/ | makes Mail data available via Apache Mime4J | |||
SimpleGraph-MapSystem | MapSystem | map | MapSystem | https://en.wikipedia.org/wiki/Hash table | java.api.Map | https://docs.oracle.com/javase/8/docs/api/java/util/Map.html | supplies a simple wrapper for a graph with nodes that have key/value pairs in form of HashMaps. We would not really need this since Apache Tinkerpop/Gremlin already supplies us with properties per node/vertex. Still this system is useful as a helper system and to illustrate the wrapping concepts and possibilities of SimpleGraph | |
SimpleGraph-MediaWiki | MediaWiki | mediawiki | MediaWikiSystem | https://www.mediawiki.org/wiki/API:Main page MediaWiki | MediaWiki API | https://www.mediawiki.org/wiki/API:Main page | makes MediaWiki site content accessible to Graph processing. It exposes the MediaWiki API using the mediawiki-japi Library by BITPlan. | |
SimpleGraph-PDF | PdfSystem | https://de.wikipedia.org/wiki/Portable Document Format | Apache PDFBox | https://pdfbox.apache.org/ | makes Portable Document Format (PDF) files accessible via the Apache PDFBox® API | |||
SimpleGraph-PowerPoint | PowerPoint | powerpoint | PowerPointSystem | https://en.wikipedia.org/wiki/Microsoft PowerPoint | Apache POI XSLF/HSLF | https://poi.apache.org/slideshow/xslf-cookbook.html | makes Microsoft PowerPoint presentations accessible via the Apache POI API | |
SimpleGraph-SMW | SMW | smw | SmwSystem | https://en.wikipedia.org/wiki/SMW | SemanticMedia Wiki API | https://www.semantic-mediawiki.org/wiki/Help:API | makes Semantic MediaWiki accessible via the SMW API | |
SimpleGraph-SNMP | SNMP | snmp | SNMPSystem | https://en.wikipedia.org/wiki/Simple Network Management Protocol | SNMP4J Simple Network Monitoring Protocol SNMP Java API | http://www.snmp4j.org/ | makes Simple Network Monitoring Protocol accessible via SNMP4J | |
SimpleGraph-SQL | SQL | sql | SQLSystem | https://en.wikipedia.org/wiki/SQL | Java Database Connectivity (JDBC) API | https://docs.oracle.com/javase/8/docs/api/java/sql/package-summary.html | makes relational SQL databases accessible via the Java JDBC API. | |
SimpleGraph-TripleStore | TripleStore | triplestore | TripleStoreSystem | https://en.wikipedia.org/wiki/Triplestore | SiDIF-TripleStore | https://github.com/BITPlan/org.sidif.triplestore | makes BITPlan's SiDIF educational TripleStore accessible | |
SimpleGraph-WikiData | WikiData | wikidata | WikiDataSystem | https://en.wikipedia.org/wiki/Wikidata | WikiData Toolkit | https://github.com/Wikidata/Wikidata-Toolkit | makes WikiData data available via the Wikidata-Toolki API | |
SimpleGraph-Word | Word | word | WordSystem | https://en.wikipedia.org/wiki/Word | Apache POI XWPF/HWPF | https://poi.apache.org/document/quick-guide-xwpf.html | makes Microsoft Word Documents accessible via the Apache POI API | |
SimpleGraph-XML | XML | xml | XmlSystem | https://en.wikipedia.org/wiki/XML | org.w3c.dom | https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/package-summary.html | makes XML dom parse results accessible to Graph processing. | |
SimpleGraph-github | GitHub | github | GitHubSystem | https://github.com | GitHub GraphQL Api v4 | https://developer.github.com/v4/ | makes GitHub content accessible to Graph processing. |
The corresonding SMW ask query is
{{#ask: [[Concept:SimpleGraphModule]] |mainlabel=SimpleGraphModule |?SimpleGraphModule name = name |?SimpleGraphModule logo = logo |?SimpleGraphModule modulename = modulename |?SimpleGraphModule systemname = systemname |?SimpleGraphModule url = url |?SimpleGraphModule apiname = apiname |?SimpleGraphModule apiurl = apiurl |?SimpleGraphModule documentation = documentation |format=table |order=?SimpleGraphModule name }}
JUnit Test
The following Unit Test now shows how you can convert such an Ask Query to a graph structure. Each result row will be converted to a Vertex in the graph. The name of the Vertex is derived from the Concept-Name you queried automatically (if there is a Concept condition in the query). You can also give the name of the vertex labels as parameter.
public void testSimpleGraphModules() throws Exception {
String askQuery = "{{#ask: [[Concept:SimpleGraphModule]]\n"
+ "|mainlabel=SimpleGraphModule\n"
+ "| ?SimpleGraphModule name = name\n"
+ "| ?SimpleGraphModule logo = logo\n"
+ "| ?SimpleGraphModule modulename = modulename\n"
+ "| ?SimpleGraphModule systemname = systemname\n"
+ "| ?SimpleGraphModule url = url\n"
+ "| ?SimpleGraphModule apiname = apiname\n"
+ "| ?SimpleGraphModule apiurl = apiurl\n"
+ "| ?SimpleGraphModule documentation = documentation\n" + "}}";
SmwSystem smw = new SmwSystem();
// debug = true;
smw.setDebug(debug);
smw.connect("http://wiki.bitplan.com", "/");
smw.moveTo("ask=" + askQuery);
if (debug)
smw.forAll(SimpleNode.printDebug);
List<Vertex> moduleVs = smw.getStartNode().g().V()
.hasLabel("SimpleGraphModule").toList();
}
Module for SE: true