{"_id":"jassa","_rev":"20-763077ee54de27df5d6be26fcd3b3e8a","name":"jassa","description":"JAvascript Suite for Sparql Access","dist-tags":{"latest":"0.5.0"},"versions":{"0.0.1":{"name":"jassa","version":"0.0.1","description":"JAvascript Suite for Sparql Access","main":"./jassa.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":"","author":{"name":"Claus Stadler"},"license":"BSD","readme":"## Sponate: Tackling the SPARQL-JSON impedance mismatch\n\nLaunched Sept 28 2013. As of Oct 4, 2013, there is only (or already) a teaser yet.\n\n### Motivation and Vision\nJSON and template engines go together like butter and bread for creating awesome HTML views with little or no coding.\\* \nThe same relation holds between SPARQL and Open Data: up to now, this is probably one of the best ways to publish data in an easily reusable way.\\*\\*\nHowever, combining SPARQL with JSON is often painful, as the data models simply don't match up.\n\nThis pain is similar to the one which one encounters when mapping between relational database management systems and object oriented languages.\n\nAnd this is where Sponate jumps in.\n'Sponate' mixes the technologies SParql, jsON, hiberNATE, but also [Jena](http://jena.apache.org/), and [mongoDB](http://docs.mongodb.org). And for the teaser also angular.\nSponate allows one declare mappings between SPARQL elements and JSON document templates. Queries can be performed over these JSON templates using a mongoDB like API.\n\n\n\\* If you are unfamiliar with template engines, check out [angular](http://angularjs.org/),  [handlebars](http://handlebarsjs.com/), [mustache](http://mustache.github.io/), or have a look at the [template-engine-chooser](http://garann.github.io/template-chooser/)\n\n\\*\\* A discussion is out of scope, but the main reasons are:\n* SPARQL is a standardized query language for web databases, and those databases are becoming increasingly popular with the growth of the [LOD cloud](http://lod-cloud.net/).\n* The underlying data model, called `RDF`, makes it possible to create links between individual pieces of data, which is not possible to this extent using formats such as JSON, XML, CSV and so on.\n* And with RDF in some cases people are actually finding consensus on quasi-standard schemas for common modeling problems.\n\n\n### Components\nSponate is a module of the JAvascript Suite for Sparql Access (JASSA), which is structured as follows:\n\n* `Jassa.rdf`: A port of some core Jena classes. The most prominent class is [Jassa.rdf.Node](https://github.com/GeoKnow/Sponate/blob/master/jassa-js/src/main/webapp/resources/js/rdf/rdf-core.js).\n* `Jassa.sparql`: A port of some Jena sparql classes. These are used to create queries in a structured fashion. Builds on top of the rdf namespace.\n* `Jassa.sponate`: The sponate system is located in this namespace and builds on top of the other two.\n\n\nIf you have used Java jena before, you will notice that the interfaces are (almost) identical.\n\n\n### Teaser\nA simple demo is already working and available [here](http://cstadler.aksw.org/jassa/sponate/).\nIt works directly on DBpedia and creates a table showing castles together with their list of owners (some have more than 1).\nHave a look at the source code how it is done - it's less than 100 lines.\n\n\n    var service = sponate.ServiceUtils.createSparqlHttp('http://dbpedia.org/sparql', ['http://dbpedia.org']);\n    var store = new sponate.StoreFacade(service, prefixes);\n\n    store.addMap({\n        name: 'castles',\n        template: [{\n            id: '?s',\n            name: '?l',\n            owners: [{\n                id: '?o',\n                name: '?on'\n            }]\n        }],\n        from: '?s a dbpedia-owl:Castle ; rdfs:label ?l ; dbpedia-owl:owner ?o . ?o rdfs:label ?on . Filter(langMatches(lang(?l), \"en\")) . Filter(langMatches(lang(?on), \"en\"))'\n    });\n\t\n\n    // This is a mongoDB like interface - the goal is to reach interoperability\n    store.castles.find({id: {$eq: '<http://dbpedia.org/resource/Hume_Castle>'}});\n\n\n### Getting involved\nInterested in contributing? Drop me a mail, see [here for my email](http://aksw.org/ClausStadler).\n\n### Planned features\n* Add support for rewriting criterias to SPARQL filters\n* Add support for limit and offset\n* Add support for order by\n* Add support for references/relations (oneToOne and oneToMany) between mappings\n* Add support for lazy fetching of relations based on 'hibernate-like' proxy objects\n* Test and polish\n* Integrate the faceted search components of the Faceted SPARQL browser [Facete](https://github.com/GeoKnow/Facete).\n\n\nThis project is part of [GeoKnow](http://geoknow.eu/) and maintained by the [AKSW](http://aksw.org/) research group.\n\n\n","readmeFilename":"README.md","_id":"jassa@0.0.1","dist":{"shasum":"d81f4483f11905ddf4611be1f53fc3b1144e398d","tarball":"https://registry.npmjs.org/jassa/-/jassa-0.0.1.tgz","integrity":"sha512-Pa7zt7Ng5I97zhQxAjrpGbL5kPaYQnAuix/nlgpW7BUh0kD4PravW5+Az+VOg8pMTcfLHHURBW2kt3nfYf5GpA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQChpS05+NUTZKByKXMITtdWWaXNpl+otN/kTeOFKno+0gIgf+Q526KHKotyC+smPFxrRmfRlsE4FlK5+N0NR4VkaTc="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"aklakan","email":"cstadler@informatik.uni-leipzig.de"},"maintainers":[{"name":"aklakan","email":"cstadler@informatik.uni-leipzig.de"}],"directories":{}},"0.5.0":{"name":"jassa","version":"0.5.0","description":"JAvascript Suite for Sparql Access","main":"./jassa.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/GeoKnow/Jassa.git"},"author":{"name":"Claus Stadler"},"license":"BSD","dependencies":{"xmlhttprequest":"~1.6.0","jquery":"~1.8.3","underscore":"~1.5.2","underscore.string":"~2.3.3","prototype":"~0.0.5"},"readme":"## JAvascript Suite for Sparql Access (Jassa)\n\nThis repository contains several tools for JavaScript based Sparql access. It works both from the client side from the browser and server side with nodejs.\n\nThe highlights of this repository are:\n\n* A high level JavaScript API for RDF. Provides core RDF classes (such as Node and Triple), SPARQL classes (such as Query, Element, Expr) and Service classes (such QueryExecutionFactoryHttp, QueryExecutionHttp). If you are familiar with [Apache Jena](http://jena.apache.org), you have most likely seen these names before.\n* The _Facete_-API, a powerful faceted search API for generic faceted search on SPARQL endpoints. Under heavy development - TODO Add demo link.\n* The _Sponate_-API, a SPARQL-to-JSON mapper which is somewhat similar to [Hibernate](http://hibernate.org) (Sponate = SParql, jsON, hiberNATE). This component unfolds its full potential in combination with latest generation frameworks that keep the DOM and controller logic separate, e.g. [AngularJS](http://angularjs.org/). (Possibly also [Ember.js](http://emberjs.com/), but at present we only develop using the former framework).\n\n## Terminology\n\nYou may have noticed that we repeatedly used the term '''class'''. While it is true that plain JavaScript does not offer them (yet), there are however frameworks which introduce this level of abstraction. For Jassa we chose the [Class object](https://github.com/sstephenson/prototype/blob/master/src/prototype/lang/class.js) of the [prototype.js framework](http://prototypejs.org/).\n\nPersonal anecdote: Use of classes (and inheritance) at least doubled my JavaScript productivity - if you are working on a sufficiently complex project, never ever listen to the voices that tell you that design is overrated (and there are many in the JS community) - its everything! (TODO Most likely someone famous could be quoted here) ;)\n\n## How to obtain\n\n* npm \n\n        npm install jassa\n\n* bower\n\n        Will come once bower does not silently exit with status code 1 ...\n\n* direct download\n\n        to be done...\n\n\n## Dependencies\n\nJassa depends on the following libraries:\n\n* `jquery`: Asynchronous requests are based on $.ajax\n* `prototype`: Only the `Class` object is needed from prototype.\n* `underscore`: Provides several utility functions for working with (associative) arrays.\n* `underscore.string`: Provides several utility function for working with strings.\n* `xmlhttprequest`: NodeJs only; i.e. not needed for browser based set up. This library emulates the browser's XMLHttpRequest object, and makes jQuery's $.ajax work from nodejs. Include it before jQuery.\n\n\n## Browser-based Set Up\n\nAdjust paths and versions to your needs.\n\n```html\n<html>\n    <head>\n        <script src=\"resources/libs/jquery/1.9.1/jquery.js\"></script>\n        <script src=\"resources/libs/underscore/1.4.4/underscore.js\"></script>\n        <script src=\"resources/libs/underscore.string/2.3.0/underscore.string.js\"></script>\n        <script src=\"resources/libs/prototype/1.7.1/prototype.js\"></script>\n\n        <script src=\"resources/libs/jassa/0.5.0/jassa.js\"></script>\n\n        <script type=\"text/javascript\">\n            _.mixin(_.str.exports());\n\n            // The Jassa object is now readily available\n            // We hope that the name Jassa is sufficiently exotic to never cause a name clash\n            // But who knows. I wished JavaScript had native namespace support...\n        console.log(\"The Jassa object: \", Jassa);\n        </script>\n    </head>\n</html>\n```\n\n## NodeJs-based Set Up\n\nExample of a nodejs based set up:\n\n```js\nvar XMLHttpRequest = require(\"xmlhttprequest\").XMLHttpRequest;\n\n$ = require('jquery');\n\n$.support.cors = true;\n$.ajaxSettings.xhr = function () {\n    return new XMLHttpRequest;\n}\n\nrequire('prototype');\n\n_ = require('underscore');\n_.str = require('underscore.string');\n\n_.mixin(_.str.exports());\n\nvar Jassa = require('jassa');\n```\n\n\n## Components and Usage\n\nThe `Jassa` object defines the following modules\n\n### The `rdf` and `vocab` modules\n\nThe `rdf` module holds core RDF classes which are similar to those of Jena.\nThe `vocab` module defines the following vocabularies (work in progress):\n\n* xsd\n* rdf\n* rdfs\n* owl\n* wgs84\n\nThese two modules depend on each other (and thus cannot be used separately), because the vocabulary is expressed in\nterms of `rdf` classes, however literals require the xsd vocabulary.\n\nExample usage:\n\n```js\nvar rdf = Jassa.rdf;\nvar vocab = Jassa.vocab;\n\nvar s = rdf.NodeFactory.createVar(\"s\");\nvar p = vocab.rdf.type;\nvar o = rdf.NodeFactory.createUri(\"http://example.org/ontology/MyClass\");\n\nvar triple = new ns.Triple(s, p, o);\n\nconsole.log(\"Triple: \" + triple);\nconsole.log(\"Subject is a variable: \" + triple.getSubject().isVar());\n```\n\n### The `sparql` module\n\nThe `sparql` module contains several classes for the syntactic\nrepresentation of SPARQL queries. In addition to the `Query` class, there\nalse exist the `Expr` and `Element` class hierarchies known from Apache Jena.\n\nExample usage:\n\n```js\nvar rdf = Jassa.rdf;\nvar sparql = Jassa.sparql;\n\nvar query = new sparql.Query();\nvar s = rdf.NodeFactory.createVar(\"s\");\nvar p = rdf.NodeFactory.createVar(\"p\");\nvar o = rdf.NodeFactory.createVar(\"o\");\n\nvar triple = new rdf.Triple(s, p, o);\n\nquery.setElement(new sparql.ElementTriplesBlock([triple]));\nquery.setResultStar(true);\nquery.setLimit(10);\n\nconsole.log(\"QueryString: \" + query);\n```\n\n### The `service` module\n\nThe service module provides an abstraction layer for communicating with a SPARQL endpoint.\n\n```js\nvar service = Jassa.rdf;\n\nvar qef = new service.QueryExecutionFactoryHttp(\n          \"http://dbpedia.org/sparql\",\n          [\"http://dbpedia.org\"]\n);\n\nvar qe = qef.createQueryExecution(\"Select * { ?s ?p ?o } Limit 10\");\nqe.setTimeout(5000); // timout in milliseconds\n\nqe.execSelect()\n    .done(function(rs) {\n        while(rs.hasNext()) {\n            var binding = rs.nextBinding();\n            console.log(\"Got binding: \" + binding);\n        }\n    })\n    .fail(function(err) {\n        console.log(\"An error occurred: \", err);\n    });\n```\n\nSuccessful execution of a SPARQL queries yields a `ResultSet` object, which is essentially an iterator over `Binding` objects.\nA binding is a map that associates variables with values (instances of `rdf.Node`) or null.\nObviously, this API in principle frees you from the hassle of dealing with a concrete SPARQL result set format.\nCurrently, the API is only implemented for SPARQL endpoints that yield [Talis RDF JSON](http://docs.api.talis.com/platform-api/output-types/rdf-json).\n\n### Facete\n\nFacete is library for faceted search based on _concepts_ and _constraints_.\nConceptually, a facete-concept is a pair comprised of SPARQL graph pattern and a variable that appears in it.\n\nFacete then allows one to retrieve a concept's properties and sub-properties under a (possibly empty) set of constraints.\n\nTODO Add demo, complete example below (service is missing)\n\n```js\nvar service = Jassa.service;\nvar facete = Jassa.facete;\n\nvar constraintManager = new facete.ConstraintManager();\n\nvar baseVar = rdf.NodeFactory.createVar(\"s\");\nvar baseConcept = facete.ConceptUtils.createSubjectConcept(baseVar);\nvar rootFacetNode = facete.FacetNode.createRoot(baseVar);\n\n// Based on above objects, create a provider for the configuration\n// which the facet service can build upon\nvar facetConfigProvider = new facete.FacetGeneratorConfigProviderIndirect(\n\tnew facete.ConceptFactoryConst(baseConcept),\n\tnew facete.FacetNodeFactoryConst(rootFacetNode),\n\tconstraintManager\n);\n\nvar fcgf = new facete.FacetConceptGeneratorFactoryImpl(facetConfigProvider);\nvar facetConceptGenerator = fcgf.createFacetConceptGenerator();\n\n\nvar expansionSet = new util.HashSet();\nexpansionSet.add(new facete.Path());\n\nvar facetService = new facete.FacetServiceImpl(qef, facetConceptGenerator);\nvar facetTreeService = new facete.FacetTreeServiceImpl(facetService, expansionSet);\n\nfacetService.fetchFacets()\n    .done(function(facetTree) {\n        console.log(\"FacetTree: \" + JSON.stringify(facetTree));\n    })\n    .fail(function(err) {\n        console.log(\"An error occurred: \", err);\n    });\n```\n\n### Sponate\n\nSponate is a SPARQL-to-JSON mapper.\nTODO Add more description...\n\n```js\nvar service = Jassa.service;\nvar sponate = Jassa.sponate;\n\nvar prefixes = {\n\t'dbpedia-owl': 'http://dbpedia.org/ontology/',\n\t'dbpedia': 'http://.org/resource/',\n\t'rdfs': 'http://www.w3.org/2000/01/rdf-schema#',\n\t'foaf': 'http://xmlns.com/foaf/0.1/'\n};\n\nvar qef = new service.QueryExecutionFactoryHttp('http://dbpedia.org/sparql', ['http://dbpedia.org']);\t\n\nvar store = new sponate.StoreFacade(qef, prefixes);\n\nstore.addMap({\n\tname: 'castles',\n\ttemplate: [{\n\t\tid: '?s',\n\t\tname: '?l',\n\t\tdepiction: '?d',\n\t\towners: [{\n\t\t\tid: '?o',\n\t\t\tname: '?on'\n\t\t}]\n\t}],\n\tfrom: '?s a dbpedia-owl:Castle ; rdfs:label ?l ; '\n\t     + 'foaf:depiction ?d ; dbpedia-owl:owner ?o .'\n\t     + '?o rdfs:label ?on .'\n\t     + 'Filter(langMatches(lang(?l), \"en\"))'\n\t     + 'Filter(langMatches(lang(?on), \"en\"))'\n});\n\nvar criteria = {name: {$regex: filterText}};\nvar flow = store.castles.find(criteria).limit(10).skip(10)\n\nflow.asList()\n\t.done(function(docs) {\n\t    _(docs).each(function(doc) {\n\t        console.log(\"JSON document: \" + JSON.stringify(doc));\n\t    });\n\t})\n\t.fail(function(err) {\n        console.log(\"An error occurred: \", err);\n\t});\n```\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/GeoKnow/Jassa/issues"},"homepage":"https://github.com/GeoKnow/Jassa","_id":"jassa@0.5.0","dist":{"shasum":"1ee28dd4f6959d27640d2204db26778e93f899e2","tarball":"https://registry.npmjs.org/jassa/-/jassa-0.5.0.tgz","integrity":"sha512-ujEsUaEw6hlMRlq2YmcrCQ4DvS/aKFRn2H0W+aeWFsDG40D2zcKxG7UeRf9RhrARNxD+RE+O/J8QtR/tijXdvw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDld/bnlLKr37Vk8rnCuK7EGyoiM80E9GNF1GrCFXkmAQIhAJmqL9eySj8ryKluI+WLs7aPf0w57rdDi8Pff8Vh/7lr"}]},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"aklakan","email":"cstadler@informatik.uni-leipzig.de"},"maintainers":[{"name":"aklakan","email":"cstadler@informatik.uni-leipzig.de"}]}},"readme":"## Sponate: Tackling the SPARQL-JSON impedance mismatch\n\nLaunched Sept 28 2013. As of Oct 4, 2013, there is only (or already) a teaser yet.\n\n### Motivation and Vision\nJSON and template engines go together like butter and bread for creating awesome HTML views with little or no coding.\\* \nThe same relation holds between SPARQL and Open Data: up to now, this is probably one of the best ways to publish data in an easily reusable way.\\*\\*\nHowever, combining SPARQL with JSON is often painful, as the data models simply don't match up.\n\nThis pain is similar to the one which one encounters when mapping between relational database management systems and object oriented languages.\n\nAnd this is where Sponate jumps in.\n'Sponate' mixes the technologies SParql, jsON, hiberNATE, but also [Jena](http://jena.apache.org/), and [mongoDB](http://docs.mongodb.org). And for the teaser also angular.\nSponate allows one declare mappings between SPARQL elements and JSON document templates. Queries can be performed over these JSON templates using a mongoDB like API.\n\n\n\\* If you are unfamiliar with template engines, check out [angular](http://angularjs.org/),  [handlebars](http://handlebarsjs.com/), [mustache](http://mustache.github.io/), or have a look at the [template-engine-chooser](http://garann.github.io/template-chooser/)\n\n\\*\\* A discussion is out of scope, but the main reasons are:\n* SPARQL is a standardized query language for web databases, and those databases are becoming increasingly popular with the growth of the [LOD cloud](http://lod-cloud.net/).\n* The underlying data model, called `RDF`, makes it possible to create links between individual pieces of data, which is not possible to this extent using formats such as JSON, XML, CSV and so on.\n* And with RDF in some cases people are actually finding consensus on quasi-standard schemas for common modeling problems.\n\n\n### Components\nSponate is a module of the JAvascript Suite for Sparql Access (JASSA), which is structured as follows:\n\n* `Jassa.rdf`: A port of some core Jena classes. The most prominent class is [Jassa.rdf.Node](https://github.com/GeoKnow/Sponate/blob/master/jassa-js/src/main/webapp/resources/js/rdf/rdf-core.js).\n* `Jassa.sparql`: A port of some Jena sparql classes. These are used to create queries in a structured fashion. Builds on top of the rdf namespace.\n* `Jassa.sponate`: The sponate system is located in this namespace and builds on top of the other two.\n\n\nIf you have used Java jena before, you will notice that the interfaces are (almost) identical.\n\n\n### Teaser\nA simple demo is already working and available [here](http://cstadler.aksw.org/jassa/sponate/).\nIt works directly on DBpedia and creates a table showing castles together with their list of owners (some have more than 1).\nHave a look at the source code how it is done - it's less than 100 lines.\n\n\n    var service = sponate.ServiceUtils.createSparqlHttp('http://dbpedia.org/sparql', ['http://dbpedia.org']);\n    var store = new sponate.StoreFacade(service, prefixes);\n\n    store.addMap({\n        name: 'castles',\n        template: [{\n            id: '?s',\n            name: '?l',\n            owners: [{\n                id: '?o',\n                name: '?on'\n            }]\n        }],\n        from: '?s a dbpedia-owl:Castle ; rdfs:label ?l ; dbpedia-owl:owner ?o . ?o rdfs:label ?on . Filter(langMatches(lang(?l), \"en\")) . Filter(langMatches(lang(?on), \"en\"))'\n    });\n\t\n\n    // This is a mongoDB like interface - the goal is to reach interoperability\n    store.castles.find({id: {$eq: '<http://dbpedia.org/resource/Hume_Castle>'}});\n\n\n### Getting involved\nInterested in contributing? Drop me a mail, see [here for my email](http://aksw.org/ClausStadler).\n\n### Planned features\n* Add support for rewriting criterias to SPARQL filters\n* Add support for limit and offset\n* Add support for order by\n* Add support for references/relations (oneToOne and oneToMany) between mappings\n* Add support for lazy fetching of relations based on 'hibernate-like' proxy objects\n* Test and polish\n* Integrate the faceted search components of the Faceted SPARQL browser [Facete](https://github.com/GeoKnow/Facete).\n\n\nThis project is part of [GeoKnow](http://geoknow.eu/) and maintained by the [AKSW](http://aksw.org/) research group.\n\n\n","maintainers":[{"name":"aklakan","email":"cstadler@informatik.uni-leipzig.de"}],"time":{"modified":"2022-06-19T03:50:02.051Z","created":"2013-11-12T13:33:55.673Z","0.0.1":"2013-11-12T13:34:04.485Z","0.5.0":"2013-11-28T00:42:51.117Z"},"author":{"name":"Claus Stadler"},"repository":{"type":"git","url":"https://github.com/GeoKnow/Jassa.git"},"users":{"duraark":true}}