Hi, everyone , i need to get specific set of triple from my model Jena, i have a very large set of triple and i want to check a specifc predicate for each Graph (with graph i mean a set o triple with the same subject), i show you a example:
<http://myOntology#A> <http://schema.org/name> "Name". <http://myOntology#A> <http://schema.org/surname> "Surname". <http://myOntology#A> <http://schema.org/fullname> "Name Surname". <http://myOntology#B> <http://schema.org/name> "Name". <http://myOntology#B> <http://schema.org/fullname> "Name Surname". In this case i want to Get only the A resource or delete the B resource,because the B don't have the triple with predicate surname, I know i can do it with the SPARQL query and use Jena to get the result , but for my reason i need to use a for or iterator cicle. something like this: //LOAD MY MODEL Model model = ModelFactory.createDefaultModel(); InputStream in = com.hp.hpl.jena.util.FileManager.get().open( filepath+"\\"+filename ); if (in == null) { throw new IllegalArgumentException( "File: " + filepath+"\\"+filename + " not found"); } RDFDataMgr.read(model, in, org.apache.jena.riot.Lang.N3); //GET A LIST OF ALL STATEMENT WITH SAME SUBJECT....... List<List<Statement>> graphics = ............... //here i need help //....WHERE THESE STATEMENT HAVE THE SAME SUBJECT Statement stat1= graphics[0][1] Statement stat2 = graphics[0][2] .......................... //.......SO IN THE END for(List<Statement> listStat : graphics){ for(Statement sot : listStat){ if(sot.getPredicate().toString().Contains(" http://schema.org/surname")) { //OK }else{ //FAIL } } } Ty in advance. Greetings.
