I am trying to create some statements and their inverse in Java using OpenRDF's Sesame. I am following the tutorial in the Sesame 2.7 documentation as well. Let's say I have created the following URIs and statements and added them to the Sesame repository:
RepositoryConnection connection;
ValueFactory factory = ValueFactoryImpl.getInstance();
Resource author_1 = new createURI("http://www.author.org/author_1");
Resource article_1 = new createURI("http://www.title.org/article_1");
URL wrote = factory.createURI("http://www.paper.org/wrote");
URL writtenby = factory.createURI("http://www.paper.org/writtenby");
Statement statement_1 = factory.createStatement(author_1, wrote, article_1);
connection.add(statement_1);
The code above is for creating a statement to describe that an author wrote an article. In the OpenRDF Workbench, I can see this statement. What I am trying to do is to do the inverse using OWL.INVERSEOF to get that article_1 is written by author_1 as follows:
connection.add(writtenby, OWL.INVERSEOF, wrote);
When I run the project and get back to the OpenRDF Workbench, I see the following statements:
<http://www.author.org/author_1>, http://www.paper.org/wrote, http://www.title.org/article_1>
<http://www.paper.org/writtenby>, <http://www.w3.org/2002/owl#inverseOf>, <http://www.paper.org/wrote>
When I click on <http://www.paper.org/writtenby>, I can't find the inverse statement that the article_1 is written by author1 but I can find the author_1 wrote article_1. Is my way of doing this inverse wrong or do I misunderstand something with this concept? Thank you very much for your help in advance.
It is as Joshua says. OpenRDF/Sesame doesn't have support for this kind of reasoning. I think it supports only some kind of basic RDF/S reasoning during load. It also (still) doesn't support custom rules I think.
You can achieve what you are asking by using Sesame with OWLIM. OWLIM-Lite and OWLIM-SE do have support for OWL reasoning (rule-based, forward-chaining, materialization). There is a number of predefined rule sets supported by OWLIM. You would probably want owl-max.
Depending on what you are trying to achieve, you might want to use a real OWL reasoner such as Pellet. However, Sesame doesn't support Pellet...
Related
First of all, I want to clarify that my experience working with wikidata is very limited, so feel free to correct if any of my terminology is wrong.
I've been playing with wikidata toolkit, more specifically their wdtk-wikibaseapi. This allows you to get entity information and their different properties as such:
WikibaseDataFetcher wbdf = WikibaseDataFetcher.getWikidataDataFetcher();
EntityDocument q42 = wbdf.getEntityDocument("Q42");
List<StatementGroup> groups = ((ItemDocument) q42).getStatementGroups();
for(StatementGroup g : groups) {
List<Statement> statements = g.getStatements();
for(Statement s : statements) {
System.out.println(s.getMainSnak().getPropertyId().getId());
System.out.println(s.getValue());
}
}
The above would get me the entity Douglas Adams and all the properties under his site: https://www.wikidata.org/wiki/Q42
Now wikidata toolkit has the ability to load and process dump files, meaning you can download a dump to your local and process it using their DumpProcessingController class under the wdtk-dumpfiles library. I'm just not sure what is meant by processing.
Can anyone explain me what does processing mean in this context?
Can you do something similar to what was done using wdtk-wikibaseapi in the example above but using a local dump file and wdtk-dumpfiles i.e. get an entity and it's respective properties? I don't want to get the info from online source, only from the dump (offline).
If this is not possible using wikidata-toolkit, could you point me to somewhere that can get me started on getting entities and their properties from a dump file for wikidata please? I am using Java.
I am new to Android and Windows Azure. I have successfully inserted data from Android application but how do I retrieve single data and post that data on a TextView?
The read function after the gettable class is also not working. What is the exact function use for it? I have followed these instructions but they did not work for me, also I do not understand the documentation.
Currently, I just can provide some tutorials about how to use query data from azure database. I recommend you can refer to this official document about how to use Azure Client Library using Java: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-android-how-to-use-client-library . You can focus on two part: “how to query data from a mobile service” and “how to bind data to the UI”.
At the same time, you can view this video from Channel 9: https://channel9.msdn.com/Series/Windows-Azure-Mobile-Services/Android-Getting-Started-With-Data-Connecting-your-app-to-Windows-Azure-Mobile-Services.
The sample code project of this tutorial, please go to the GitHub link https://github.com/Azure/mobile-services-samples/tree/master/GettingStartedWithData .
For the ‘getTable(Class )’ function is not working, please double check whether the class name is same as table name. If they are same, you can use it like below:
MobileServiceTable<ToDoItem> mToDoTable = mClient.getTable(ToDoItem.class);
If not, you can write you code like this:
MobileServiceTable<ToDoItem> mToDoTable = mClient.getTable("ToDoItemBackup", ToDoItem.class);
For further better support, please share more detail about your code snippet .
Is there a way to generate BPEL programmatically in Java?
I tried using the BPEL Eclipse Designer API to write this code:
Process process = null;
try {
Resource.Factory.Registry reg =Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("bpel", new BPELResourceFactoryImpl());//it works with XMLResourceFactoryImpl()
//create resource
URI uri =URI.createFileURI("myBPEL2.bpel");
ResourceSet rSet = new ResourceSetImpl();
Resource bpelResource = rSet.createResource(uri);
//create/populate process
process = BPELFactory.eINSTANCE.createProcess();
process.setName("myBPEL");
Sequence mySeq = BPELFactory.eINSTANCE.createSequence();
mySeq.setName("mainSequence");
process.setActivity(mySeq);
//save resource
bpelResource.getContents().add(process);
Map<String,String> map= new HashMap<String, String>();
map.put("bpel", "http://docs.oasis-open.org/wsbpel/2.0/process/executable");
map.put("tns", "http://matrix.bpelprocess");
map.put("xsd", "http://www.w3.org/2001/XMLSchema");
bpelResource.save(map);
}
catch (Exception e) {
e.printStackTrace();
}
}
but I received an error:
INamespaceMap cannot be attached to an eObject ...
I read this message by Simon:
I understand that using the BPEL model outside of eclipse might be desirable, but it was never intended by us. Thus, this isn't supported
Is there any other API that can help?
You might want to give JAXB a try. It helps you to transform the official BPEL XSD into Java classes. You use those classes to construct your BPEL document and output it.
I had exactly the same problem with the BPELUnit [1], so I started a module in BPELUnit that has the first things necessary for generating and reading BPEL Models [2] although it is far from complete. Supported is only BPEL 2.0 (1.1 will follow later) and handlers are also currently not supported (but will be added). It is under active development because BPELUnit's code coverage component will be based on it so it will get BPEL-feature complete over time. You are happily invited to contribute if you need to close gaps earlier.
You can check it out from GitHub or grap the Maven artifact.
As of now there is no documentation but you can have a look at the JUnit tests that read and write processes.
If this is not suitable for, I'd like to share some experiences with you:
Do not use JAXB: You will need to read and write XML Namespaces which are not preserved with JAXB. That's why I have chosen XMLBeans. DOM would be the other alternative that I can think of.
The inheritance in the XML Schema is not really developer friendly. That's why there are own interface structures and wrappers around the XMLBeans generated classes.
Daniel
[1] http://www.bpelunit.net
[2] https://github.com/bpelunit/bpelunit/tree/master/net.bpelunit.model.bpel
This has been solved using the unify framework API after adding the necessary classes to handle correlation. BPELUnit stated by #Daniel seems to be another alternative.
The Eclipse BPEL API is based on an EMF Model. So you could generate your own artifacts using JET or Xpand based on that. This way there is no requirement to run inside Eclipse.
Although you may can't use BPEL outside of Eclipse, have you considered moving parts of your application inside it?
The BPEL XML Schemas are listed in the appendig of the spec. So you could also base your work on that and integrate with existing BPEL applications where necessary.
In case anyone is looking to solve the above problem while still running inside eclipse environment.
The problem can be resolved as stated by Luca Pino here by adding:
AdapterRegistry.INSTANCE.registerAdapterFactory( BPELPackage.eINSTANCE, BasicBPELAdapterFactory.INSTANCE );
before the resource creation line i.e.
Resource bpelResource = rSet.createResource(uri);
Note: Another solution, to the same problem, also stating how to resolve the dependencies to make this code work, can be found in my other answer here.
I have started working on a RIAK project via Spring Source.
according to their specifications linking between objects and then linkwalking is very simple.
I am saving 2 objects, linking between them and then trying to retrieve the data:
MyPojo p1 = new MyPojo("o1", "m1");
MyPojo p2 = new MyPojo("o2", "m2");
riakManager.set(bucketName1, "k1", p1);
riakManager.set(bucketName2, "k2", p2);
riakManager.link(bucketName2, "k2", bucketName1, "k1", tagName);
System.out.println(riakManager.get(bucketName1, "k1"));
System.out.println(riakManager.linkWalk(bucketName1, "k1", "_"));
the problem is that after the link, the content of the source ("k1") is deleted, only the link stays. This is the printout:
null
[MyPojo [str1=o2, str2=m2, number=200]]
any idea why link operation deletes the value from the source?
if I try to set the sources value (again) after the link, then the link gets deleted...
thanks,
oved.
Riak requires that the link and the data are stored in one operation. You can't update one without the other (at the moment).
So any time you set the link the operation must also write back the data. I don't know does the Spring adapter take that into account. I did see some messages between the Riak and Spring developers about this, but don't know if anything was fixed yet.
But in any case I am also tending towards using the native Riak Java client rather than Spring.
have decided to abandon the spring adapter. it seems it doesn't have good enough support.
using the RIAK java client instead.
anyone think otherwise?
Update: The link in the answer is both interesting and useful, but unfortunately does not address the need for a java API, so I am still looking forward to any input.
I'm building a database of chemical compounds. I need all the synonyms (IUPAC and common names) as well as safety data for each.
I'll be using the freely available data at PubChem (http://pubchem.ncbi.nlm.nih.gov/)
There's an easy way of querying each compound with simple HTTP gets. For example, to obtain glycerol data, the URL is:
http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=753
And the following URL would return an easy to parse format:
http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=753&disopt=DisplaySDF
but it will respond only very basic info, lacking safety data and only a few common names.
There is one public domain API for JAVA that seems a very complete, developed by a group at Scripps (citation). The code is here.
Unfortunately, this API is not very well documented and it's quite difficult to follow due to the complexity of the data involved.
For what I gathered, pubchemdb is using the PubChem Power User Gateway (PUG) XML API
Has anyone used this API (or any other one available)? I would appreciate a short description or tutorial on how to start with it.
The Cactvs Chemoinformatics toolkit (free for academic/educational use) has full PubChem integration. Using the scripting environment, you can easily do something like
cactvs>ens create 753
ens0
cactvs>ens get ens0 E_NAMESET
PROPANE-1,2,3-TRIOL GLYCEROL 8043-29-6 29796-42-7 30049-52-6 37228-54-9 75398-78-6 78630-16-7 8013-25-0 175385-78-1 25618-55-7 64333-26-2 56-81-5 {Tegin M} LS-1377 G8773_SIGMA 15523_RIEDEL {Glycerin, natural} NCGC00090950-03 191612_ALDRICH 15524_RIEDEL {Glycerol solution} L-glycerol 49767_FLUKA {Biodiesel impurity} 49770_FLUKA 49771_FLUKA NCGC00090950-01 49927_FLUKA Glycerol-Gelatine G7757_SIAL GOL D-glycerol G9012_SIAL {Polyhydric alcohols} c0066 MOON {NSC 9230} G2025_SIGMA ZINC00895048 49781_FLUKA {Concentrated glycerin} {Concentrated glycerin (JP15)} D00028 {Glycerin (JP15/USP)} 44892U_SUPELCO {Glycerin, concentrated (JAN)} CRY 49782_FLUKA NCGC00090950-02 G6279_SIAL W252506_ALDRICH G7893_SIAL {Glycerin, concentrated} 33224_RIEDEL Bulbold Cristal Glyceol G9281_SIGMA Glycerol-1,2,3-3H G1901_SIGMA G7043_SIGMA 1,2,3-trihydroxypropane 1,2,3-trihydroxypropanol glycerin G2289_SIAL G9406_SIGMA {Glycerol-[2-3H]} CHEBI:17754 Glyzerin Oelsuess InChI=1/C3H8O3/c4-1-3(6)2-5/h3-6H,1-2H {90 Technical glycerine} Dagralax {Glycerin, anhydrous} {Glycerin, synthetic} Glycerine Glyceritol {Glycyl alcohol} Glyrol Glysanin NSC9230 Ophthalgan Osmoglyn Propanetriol {Synthetic glycerin} {Synthetic glycerine} Trihydroxypropane Vitrosupos {WLN: Q1YQ1Q} Glycerol-1,3-14C {4-01-00-02751 (Beilstein Handbook Reference)} AI3-00091 {BRN 0635685} {CCRIS 2295} {Caswell No. 469} {Citifluor AF 2} {Clyzerin, wasserfrei [German]} {EINECS 200-289-5} {EPA Pesticide Chemical Code 063507} {FEMA No. 2525} {Glicerina [DCIT]} {Glicerol [INN-Spanish]} {Glycerin (mist)} {Glycerin [JAN]} {Glycerin mist} {Glycerine mist} Glycerinum {Glycerolum [INN-Latin]} Grocolene {HSDB 492} IFP {Incorporation factor} 1,2,3-Propanetriol C00116 Optim {Propanetriol (VAN)} {1,2,3-PROPANETRIOL, HOMOPOLYMER} {Glycerol polymer} {Glycerol, polymers} {HL 80} {PGL 300} {PGL 500} {PGL 700} Polyglycerin Polyglycerine Polyglycerol {Unigly G 2} {Unigly G 6} G5516_SIGMA MolMap_000024
cactvs>
This hides all PUG ugliness - but in any case, I dare say that PUG is well documented. The toolkit goes much beyond simple data downloads - you can even open and query PubChem like a local SD file if you want to.
PubChem does not contain safety data, though. And safety data is country/region-dependent, strictly regulated, and you should be really careful not to be hit with liabilities. Have your approach checked by legal personnel!