Jena, RDF and Jade implementation - java

I have an OWL ontology and I want to store data as RDF . When I search in the Google I saw Jena library is used for this purpose. But I could not understand how can I represent data as RDF in Jade.. Plz can somebody help me ???

Jade and Jena are more-or-less independent libraries, so using them both in a project is not hard. Indeed, they have been used in various projects - try a Google search for AgentOWL,for example.
Your agents will need one or more Jena Model objects to hold the RDF information they are going to reason with. These models can be loaded into memory in each agent instance, or you can use a persistent store, such as TDB.
When agents need to send inter-agent messages via Jade, as I recall the default mechanism that Jade uses is Java object serialization (this may have changed, it has been a while since I looked at Jade). Serialization won't work for Jena objects, you'll need to construct a model that contains just the RDF triples you want to send, and then toString() that into the content for an ACL message. I'd suggest using Turtle as the serialization format; it's more compact and easier to read.

Related

Saving Data from a JavaFX-Application without Database

Unfortunately I couldn't find anything specific to this topic / to my problem. Here we go:
I'm building a JavaFX Business Application for a friend of mine. Unfortunately I do not have any possibility to connect to a Database. I want the Application to load a savestate from a file. The application contains a list with clients and the clients got some specific properties. I do not want to hardcode this to a .prop or .txt file, because I'm sure that there's a different way of doing this, isn't there?
Thanks in advance, appreciate it!
Lots of choices for persisting data to local storage. The exact choice depends on your needs. You do not describe enough details to make a specific recommendation.
Here is a list of possibilities, roughly in increasing order of complexity of your data.
Text file
If you have small amounts of simple data, save to a text file. You can store each piece in a separate file, or combine into a single file. Recent versions of Java have new classes to make this easier than ever. See Oracle Tutorial.
Comma-separate & Tab-delimited
For sets of structured data, write to text files in comma-separated values (CSV) or tab-delimited values. For example a list of people with rows for each person, and columns for name, phone number, and email address.
While reading/writing such files is easy enough to program yourself, I suggest using an established library to eliminate the drudgery, avoid bugs, and save yourself some time. There are a few such libraries written in Java.
My favorite is the Apache Commons CSV project. This library makes easy work of the chore of reading/writing such files. Despite the name, this library supports tab-delimited as well as comma-separated formats. I've written a few Answers here on Stack Overflow showing how to use this library, as you can see here, here, and here.
By the way, plain old ASCII defines a few character positions explicitly for delimiting in data files, with four levels of grouping (document, group, record/row, and field). Unicode, of course, inherits these from ASCII as code points. I am puzzled why these have remained so obscure and so infrequently used. Seems much more logical to me than using commas and tabs which may well exist inside the data payload.
Serialization
You can write out the data values stored within an object. This is called serialization. Java has a serialization facility built-in, but be sure to study up on the details.
To more simply write out an object’s values and later read them back in to reconstitute an object, I have enjoyed using the Simple XML Serialization project. This works well for relatively simple needs, and is aimed at the situation where you want the structure of a class to drive the process of determining what to write.
Java has other XML binding facilities both built-in and third-party. These are much more powerful in their flexibility. They are especially good for when you want to define and verify the XML structure in a rigid fashion such as defining a XML DTD or XML Schema against which to validate the data and perhaps even generate the Java class in which to represent the data.
Embedded database
For more complicated data, use an embedded relational database.
The SQLite database is bundled with many platforms. This is a C-based library, not pure Java. As the name indicates, SQLite is indeed quite “lite“, lacking rigid data types and many other common database features. SQLite is meant to be an alternative to writing text files than as a competitor to more serious databases. It is a great product if your needs fit the sweet-spot of its capabilities.
My first choice for an embedded database would be H2 Database Engine. Built in pure Java. Can be run inside your app, or separately as a server (you choice). Has sophisticated relational database features. Has been around for years, often updated, and is well-worn. The principal author has much experience in the field.

How can I easily convert RDF triples to/from an idiomatic Java POJO business object?

I'm a Java developer just getting started with linked data/RDF. I can create triples, put them in a triple store, query them, etc, but it's very awkward. Most of my code is focused on the mechanics of RDF and I'd really like to work with this data in a way that's more idiomatic Java.
How can I convert a POJO to/from RDF triples with Jena without hand-coding everything?
I'd like something that can convert a pile of triples with a defined structure back and forth between a Java POJO and RDF. Like JAXB or and ORM does for XML and a relational database, respectively.
Also, I can't be locked in too closely a particular triple store. I'd really like something that works with the Apache Jena API, since that seems to be the closest to an "industry standard." Also the project architect told me to use that, since the triple stores they're investigating all support it.
Stuff I've looked at:
I try out one library that sort of does what I want, but it made some weird choices and I don't really think it will work for me.
Elmo/Alibaba also sounds promising, but it looks like it only works with the Sesame triple store and it also sounds like it may carry a big giant framework and/or server along with it. Has anyone had any success using it with Jena? I haven't actually tried it out.
There's Empire which is a partial implementation of JPA 1.0 for Object-Triple mapping. It supports Jena, Sesame, and Stardog out of the box, and is pretty easy to add support for other databases.
There's also Pinto which is more akin to Jackson. It's more lightweight than Empire and just does round-tripping to/from RDF & Java beans. It will soon be the engine inside of Empire.
Disclaimer: I'm the author of both.
Another possible tool to look at is OLGA - an Ontology SDK. See https://ecostruxure.github.io/OLGA/ .

Integrating with another Semantic Web source

I want to try and integrate my rdf data which is in an .rdf file format with dbpedia so I can build make semantic knowledge of my rdf data. Does anyone know how I would go about doing this within Jena and Java
I believe that Jena support the SPARQL 1.1 SERVICE keyword, that lets you query across a local RDF store, and DBpedia at the same time.
There's a very brief example given here: http://www.w3.org/TR/sparql11-overview/#sparql11-federated-query
You might want to have a look at Freebase, which is a system dedicated to linking semantic data. See http://www.freebase.com/ for more info.

CRUD Operation in OWL

I have created an ontology. Now I want to create an application but how can I perform CRUD operations in owl file. I came across different apis like Dotnetrdf, jena etc all support RDF/RDFS but there is not support for owl file
http://www.semanticoverflow.com/questions/2704/using-jena-to-query-owl-files
Problem of reading OWL/XML
Also, most of apis are available in Java and I dont know how to write simple hello world program in java. I am confused with servlet, jsp and .java and lots of configuration is required. So I prefer php.
So is there any api or any alternative way to query owl file in php ?
Regards,
anas anjaria
The only libraries I know that support SW standards in PHP are rdfapi [1] and redland php binding [2], but the level is RDF (i.e. the building block of RDFS and OWL) you will need to add CRUD operations at the triple level (i.e. simple axioms like foaf:knows )
[1] http://www4.wiwiss.fu-berlin.de/bizer/rdfapi/
[2] http://librdf.org/docs/php.html
So, it looks like you're talking about the Web Ontology Language, an XML/RDF dialect.
A few moments in Google shows pretty much zero interest in this in the world of PHP.
But, being XML, you can use one of the PHP XML extensions so read and work with the XML directly without a problem. How well this will actually work for you, I can't say. OWL looks freakishly complex, and working with it at the DOM node level will very likely stretch your sanity far worse than working with mature, established libraries in Java.
i made my final project at the university by using Jena. The Research Group where i work develop ontology generator tool which is capable of all crud operations. They also developed the Eclipse plug-in of this project.
You just create your OWL Data Model in the editor and right click the data model create everything, i creates owl files, Crud class and it's test codes for you.
Let's check it out
Download
Name of Plug-in is "SEAGENT Ontology Generator Plugin (Beta)"
I hope it will be beneficial for you like me

Creating Java Classes from Ontology

I have an ontology file (in RDF) which expresses the entities in the app that I am writing. I am using Jena, and can access the Concepts and create/access the resources by directly manipulating triples.
To make things easier, I created a set of Java classes, one for each type of resource in my ontology, keeping in mind their inheritances, and properties. E.g.
public class Agent{
}
and
public class Person extends Agent{
private String name;
}
If the ontology contains two types of resources, Agent and Person, with the latter being a subclass of the former.
I realized that the process of creating these classes (and the methods to extract them) are very monotonous. If I was writing an application on databases, I would have used a config file for Hibernate and let it take care of the details.
My question is: Is there a tool available that will take an ontology (in an RDF file) as input, and create a set of Java files representing the Concepts in the ontology, as in the example above? (or if Jena itself can do this, and I am missing something)
Thanks.
There are tools such as Bouml and Andromda with which you may generate Java from XMI UML serialization.
Furthermore, work has been done towards integrating UML with RDF: http://infolab.stanford.edu/~melnik/rdf/uml/.
So I guess you could find a way to transform your RDF to XMI then to generate Java from XMI, given you first map your initial RDF schema to RDF/UML.
Also I just found this paper: Automatic Mapping of OWL Ontologies into Java which I did not read so I cannot comment.
Protege supports RDF import and java export. I've used it in the past for getting ontology data into java programs and it's worked reasonably.
While going through the links provided above, I chanced upon the Trispresso Project, which provides a nice summary of the relevant tools and their features, including multiple inheritance and code generation. Thought it would make a good answer to my own question.
Did u checked JRDF? There are other code generation tools available too.. Check here.

Categories