I don't understand why you assign an integer value to a class "Team" and
not an individual like "team1" which belongs to the class "Team"
> Hello this does not sum the newly entered goals with the one already saved
> in my owl file. Every time I enter new goal (integer value), new data is
> saved and does not added(sum) with previously entered values.
>
> * int goalsss = soln.getLiteral("goal").getInt() ; //return integer value*
> *int totalgoals=goalsss+totalgoals; // total goals initial value is 0*
>
> *Literal p = model.createTypedLiteral(totalgoals);*
> * team.setPropertyValue(goals, p);// here goals is property name*
>
>
> OntModel model=ModelFactory.createOntologyModel();
> InputStream in =FileManager.get().open("D://ont/soccer.owl");
> if (in==null) {
> throw new IllegalArgumentException( "File: " + " not
> there");
> } model.read(in,"");
> String ns="http://www.semanticweb.org/neha/ontologies/2016/6/
> untitled-ontology-11#";
>
> OntClass team = model.getOntClass(ns + "Team");
> OntProperty goals=model.getOntProperty(ns+ "Goals");
>
> //Goals are entered by admin, so I want to sum the newly entered
> //goals with previous stored in ontology.
> //This is why I need integer values from these properties.
>
> SELECT *" +
> " WHERE { ?x rdf:type ont:Team . ?x ont:Goals ?goal )
> ";
>
>
> Query query = QueryFactory.create(queryString) ;
> QueryExecution qexec = QueryExecutionFactory.create(query,
> model);
> ResultSet results = qexec.execSelect() ;
> while(results.hasNext()){
> QuerySolution soln = results.nextSolution() ;
> int goalsss = soln.getLiteral("goal").getInt() ;
> int totalgoals=goalsss+totalgoals;
> Literal p = model.createTypedLiteral(totalgoals);
> team.setPropertyValue(goals, p);// here goals is property name
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center