Is it the right way to get int value from a property?

 RDFNode intValue =team1.getPropertyValue(wins);

On Sun, Oct 2, 2016 at 4:27 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> > "You have to get the "wins" value for "team1" first"
> > This is the basic problem I do not know how to get the int value from
> > "wins"?
> Not from "wins" but from the resource "team1" which is related by the
> property "wins" to an integer value. If you do not understand this, you
> will never be able to solve the problem and also do not ask the right
> questions here.
> >
> > "you first have to get the "team1" individual/resource."
> > I have individual like this:
> >  Individual team1 = team.createIndividual(ns + name); //name java
> variable.
> I told you to use Javadoc and the documentation of Jena which is quite
> good. You have to learn to use Javadoc if you're programming in Java...
>
> https://jena.apache.org/documentation/javadoc/jena/
> org/apache/jena/ontology/Individual.html
>
> Now, try to find out which method makes sense for your needs. You have a
> property and want its value(s)
> >
> > On Sat, Oct 1, 2016 at 8:20 AM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> You have to get the "wins" value for "team1" first, then set the new
> >> "wins" value for "team1" . That means you first have to get the "team1"
> >> individual/resource.
> >>
> >> RDF data model:
> >>
> >> team1 wins 3
> >>
> >> team1 = is an individual resp. a resource
> >> wins = is a data property
> >> 3 = is a literal value
> >>
> >>> I am sorry Lorenz sir,
> >>> Basically what I want to sum a team wins. When value is entered in text
> >>> field, it is saved as data property "Wins" value in the file i-e team1
> >> Wins
> >>> 3. Since this value 3 is stored in owl file, when another entry is made
> >> for
> >>> Wins property, say 2, I want to sum this new value with the previous
> >> value
> >>> of Wins property so that it does not stored in the file as:
> >>> team1 wins 2
> >>> team1 wins 3
> >>>
> >>> *but rather it is stored as:*
> >>> *team1 wins 5*
> >>>
> >>> // variable is java variable having integer value i-e 2
> >>> *Literal wins=model.createTypedLiteral(variable);*
> >>> *int win_value=wins.getInt();*
> >>>
> >>> *I just want to sum win_value (i-e  2)  with the value in data property
> >>> "Wins"*
> >>>
> >>> OntProperty winsProperty = model.getOntProperty(ns+ "Wins");
> >>>
> >>> So without SPARQL, can we get integer value of data property Wins so
> that
> >>> we can do
> >>>
> >>>  int total_wins= win_value+ (The value from data property Wins).
> >>>
> >>> Sorry again for these types of questions, but I am learning Jena course
> >> my
> >>> own and I have not studied it in my Bachelor degree (But have to use it
> >> in
> >>> my BS project)
> >>>
> >>>
> >>>
> >>> On Sat, Oct 1, 2016 at 7:07 AM, Lorenz B. <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
> >>>> What the hell are you doing here?! Javadoc + Jena documentation is
> your
> >>>> friend.
> >>>>
> >>>> It does not fetch any data, but creates a property and a literal with
> >>>> the value that is the property object which is totally wrong.
> >>>>
> >>>> First, use proper variable names.
> >>>>
> >>>>
> >>>>> Is this a proper way to fetch the int value from data property?
> >>>>>
> >>>>> OntProperty value=model.getOntProperty(ns+ "Wins");
> >>>> Obviously, this line creates a property object, i.e. call it
> "property"
> >>>> or "p" or "winsProperty" or whatever, but not value.
> >>>>
> >>>> OntProperty winsProperty = model.getOntProperty(ns+ "Wins");
> >>>>
> >>>>
> >>>>>  Literal myliteral = model.createTypedLiteral(value);
> >>>> This line creates a Literal object whose value is the property object,
> >>>> but that's totally wrong. If you want to create an int literal, use an
> >>>> integer as argument
> >>>>
> >>>> Literal myliteral = model.createTypedLiteral(3);
> >>>>
> >>>>
> >>>>
> >>>>>            int sum=myliteral.getInt();
> >>>> Again weird naming of Java variables which makes the code unreadable
> and
> >>>> even more nobody will understand what you want to achieve.
> >>>> The sum of what?
> >>>>>            sum=sum+1;
> >>>> It should be clear that data is assigned to RDF resources, that means
> >>>> you need a resource as well ,that's why the RDF data model is made of
> >>>> triples (subject, predicate, object), and from the above code you only
> >>>> have predicate and object.
> >>>>
> >>>> --
> >>>> Lorenz Bühmann
> >>>> AKSW group, University of Leipzig
> >>>> Group: http://aksw.org - semantic web research center
> >>>>
> >>>>
> >> --
> >> Lorenz Bühmann
> >> AKSW group, University of Leipzig
> >> Group: http://aksw.org - semantic web research center
> >>
> >>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>

Reply via email to