Re: addliteral() vs setpropertyvalue()

2016-10-19 Thread Lorenz B.


> Yes its true that it returns Null Pointer Exception.
It returns NULL, not a NullPointerException! That's totally different!
>
> But what you people suggest I suppose to do? One thing in my mind is to
> include first:
> employee.addLiteral(Property, 1)
> Then employee.getPropertyValue()
> Then Perform calculation/addition
> And last, employee.setPropertyValue(Property, sum/calculated value).
I don't know your programming skills, but this is more than obvious...

get the value - if this is NULL - simply set the new value - ELSE set
the existing value + the new value
>
> On Mon, Oct 17, 2016 at 12:52 AM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> Hello Tina,
>>
>>
>>
>>
>>> I want to sum 5 with the value already stored in a property.
>>>
>>> //Property "Hours" must be started from 1 and then sum 5 with it.
>>> employee.getPropertyValue(No_of_Hours);
>>> //Then perform calculations.
>>>
>>> The problem is that if I directly use employee.getPropertyValue(), it
>> gives
>>> me "Exception" (and rightly, because I did not set setPropertyValue()
>>> first).
>> That's not true. It returns null if there is no such value - and you
>> have to handle this in the code indeed.
>>> But the problem is that when I set employee.getPropertyValue(No_
>> of_Hours);
>>>  to 1 (one), it will always set the value 1(one) and not the recent
>>> added(sum) value in the property.
>>>
>>> employee.setPropertyValue(No_of_Hours, 1); //1 is literal
>>> employee.getPropertyValue(No_of_Hours);
>>> //calculations
>>> My requirement is like: int sum=No_of_Hours+1;
>>> Then No_of_Hours plus what in the *variable sum*.
>>>
>>> So can I use employee.addLiteral(No_of_Hours, 1) instead of
>>> employee.setPropertyValue().
>>>
>>> I hope you have understood what my issue is?
>>>
>>> Kindest regards
>>>
>>>
>>>
>>> On Sun, Oct 16, 2016 at 11:10 AM, Dave Reynolds <
>> dave.e.reyno...@gmail.com>
>>> wrote:
>>>
 On 16/10/16 16:59, tina sani wrote:

> Hi
>
> What is the difference between addLiteral() and setpropertyvalue()
>> when we
> want to assign values to an individual.?
> For example,
>
> //myEmployee is an instance.
>
> myEmplyee.addliteral(property, value)
> myEmployee.setpropertyvalue(property, value)
>
>
 addLiteral adds a value, so if there is already a value there you will
>> now
 have multiple values.

 setPropertyValue removes all existing values before adding the new value
 so you will only have the new value at the end.

 Dave


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



Re: addliteral() vs setpropertyvalue()

2016-10-17 Thread tina sani
Yes its true that it returns Null Pointer Exception.

But what you people suggest I suppose to do? One thing in my mind is to
include first:
employee.addLiteral(Property, 1)
Then employee.getPropertyValue()
Then Perform calculation/addition
And last, employee.setPropertyValue(Property, sum/calculated value).


On Mon, Oct 17, 2016 at 12:52 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> Hello Tina,
>
>
>
>
> > I want to sum 5 with the value already stored in a property.
> >
> > //Property "Hours" must be started from 1 and then sum 5 with it.
> > employee.getPropertyValue(No_of_Hours);
> > //Then perform calculations.
> >
> > The problem is that if I directly use employee.getPropertyValue(), it
> gives
> > me "Exception" (and rightly, because I did not set setPropertyValue()
> > first).
> That's not true. It returns null if there is no such value - and you
> have to handle this in the code indeed.
> >
> > But the problem is that when I set employee.getPropertyValue(No_
> of_Hours);
> >  to 1 (one), it will always set the value 1(one) and not the recent
> > added(sum) value in the property.
> >
> > employee.setPropertyValue(No_of_Hours, 1); //1 is literal
> > employee.getPropertyValue(No_of_Hours);
> > //calculations
> > My requirement is like: int sum=No_of_Hours+1;
> > Then No_of_Hours plus what in the *variable sum*.
> >
> > So can I use employee.addLiteral(No_of_Hours, 1) instead of
> > employee.setPropertyValue().
> >
> > I hope you have understood what my issue is?
> >
> > Kindest regards
> >
> >
> >
> > On Sun, Oct 16, 2016 at 11:10 AM, Dave Reynolds <
> dave.e.reyno...@gmail.com>
> > wrote:
> >
> >> On 16/10/16 16:59, tina sani wrote:
> >>
> >>> Hi
> >>>
> >>> What is the difference between addLiteral() and setpropertyvalue()
> when we
> >>> want to assign values to an individual.?
> >>> For example,
> >>>
> >>> //myEmployee is an instance.
> >>>
> >>> myEmplyee.addliteral(property, value)
> >>> myEmployee.setpropertyvalue(property, value)
> >>>
> >>>
> >> addLiteral adds a value, so if there is already a value there you will
> now
> >> have multiple values.
> >>
> >> setPropertyValue removes all existing values before adding the new value
> >> so you will only have the new value at the end.
> >>
> >> Dave
> >>
> >>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: addliteral() vs setpropertyvalue()

2016-10-17 Thread Lorenz B.
Hello Tina,

 


> I want to sum 5 with the value already stored in a property.
>
> //Property "Hours" must be started from 1 and then sum 5 with it.
> employee.getPropertyValue(No_of_Hours);
> //Then perform calculations.
>
> The problem is that if I directly use employee.getPropertyValue(), it gives
> me "Exception" (and rightly, because I did not set setPropertyValue()
> first).
That's not true. It returns null if there is no such value - and you
have to handle this in the code indeed.
>
> But the problem is that when I set employee.getPropertyValue(No_of_Hours);
>  to 1 (one), it will always set the value 1(one) and not the recent
> added(sum) value in the property.
>
> employee.setPropertyValue(No_of_Hours, 1); //1 is literal
> employee.getPropertyValue(No_of_Hours);
> //calculations
> My requirement is like: int sum=No_of_Hours+1;
> Then No_of_Hours plus what in the *variable sum*.
>
> So can I use employee.addLiteral(No_of_Hours, 1) instead of
> employee.setPropertyValue().
>
> I hope you have understood what my issue is?
>
> Kindest regards
>
>
>
> On Sun, Oct 16, 2016 at 11:10 AM, Dave Reynolds 
> wrote:
>
>> On 16/10/16 16:59, tina sani wrote:
>>
>>> Hi
>>>
>>> What is the difference between addLiteral() and setpropertyvalue() when we
>>> want to assign values to an individual.?
>>> For example,
>>>
>>> //myEmployee is an instance.
>>>
>>> myEmplyee.addliteral(property, value)
>>> myEmployee.setpropertyvalue(property, value)
>>>
>>>
>> addLiteral adds a value, so if there is already a value there you will now
>> have multiple values.
>>
>> setPropertyValue removes all existing values before adding the new value
>> so you will only have the new value at the end.
>>
>> Dave
>>
>>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Re: addliteral() vs setpropertyvalue()

2016-10-16 Thread tina sani
I want to sum 5 with the value already stored in a property.

//Property "Hours" must be started from 1 and then sum 5 with it.
employee.getPropertyValue(No_of_Hours);
//Then perform calculations.

The problem is that if I directly use employee.getPropertyValue(), it gives
me "Exception" (and rightly, because I did not set setPropertyValue()
first).

But the problem is that when I set employee.getPropertyValue(No_of_Hours);
 to 1 (one), it will always set the value 1(one) and not the recent
added(sum) value in the property.

employee.setPropertyValue(No_of_Hours, 1); //1 is literal
employee.getPropertyValue(No_of_Hours);
//calculations
My requirement is like: int sum=No_of_Hours+1;
Then No_of_Hours plus what in the *variable sum*.

So can I use employee.addLiteral(No_of_Hours, 1) instead of
employee.setPropertyValue().

I hope you have understood what my issue is?

Kindest regards



On Sun, Oct 16, 2016 at 11:10 AM, Dave Reynolds 
wrote:

> On 16/10/16 16:59, tina sani wrote:
>
>> Hi
>>
>> What is the difference between addLiteral() and setpropertyvalue() when we
>> want to assign values to an individual.?
>> For example,
>>
>> //myEmployee is an instance.
>>
>> myEmplyee.addliteral(property, value)
>> myEmployee.setpropertyvalue(property, value)
>>
>>
> addLiteral adds a value, so if there is already a value there you will now
> have multiple values.
>
> setPropertyValue removes all existing values before adding the new value
> so you will only have the new value at the end.
>
> Dave
>
>


Re: addliteral() vs setpropertyvalue()

2016-10-16 Thread Lorenz Buehmann
Using Javadoc quite often helps...

Given that you have an Individual, you can find links at [1] to
explanations for both methods [2] [3]

[1]
https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/ontology/Individual.html

[2]
https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/rdf/model/Resource.html#addLiteral-org.apache.jena.rdf.model.Property-boolean-

[3]
https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/ontology/OntResource.html#setPropertyValue-org.apache.jena.rdf.model.Property-org.apache.jena.rdf.model.RDFNode-

On 16.10.2016 17:59, tina sani wrote:
> Hi
>
> What is the difference between addLiteral() and setpropertyvalue() when we
> want to assign values to an individual.?
> For example,
>
> //myEmployee is an instance.
>
> myEmplyee.addliteral(property, value)
> myEmployee.setpropertyvalue(property, value)
>



Re: addliteral() vs setpropertyvalue()

2016-10-16 Thread Dave Reynolds

On 16/10/16 16:59, tina sani wrote:

Hi

What is the difference between addLiteral() and setpropertyvalue() when we
want to assign values to an individual.?
For example,

//myEmployee is an instance.

myEmplyee.addliteral(property, value)
myEmployee.setpropertyvalue(property, value)



addLiteral adds a value, so if there is already a value there you will 
now have multiple values.


setPropertyValue removes all existing values before adding the new value 
so you will only have the new value at the end.


Dave