Hello Lorenz, I have assigned the value to team1 but mistakenly typed only
team.
The Chris Dollin comment about "*setPropertyValue is /documented/ as
deleting any previous value **for that property" *
*makes sense but if I write *
team1.addLiteral(goals, p), in place of team1.setPropertyValue(goals, p)

then it saves new data and the previously saved data is also there.

On Fri, Sep 30, 2016 at 4:39 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> 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
>
>

Reply via email to