Discussion:
Ont Property
Sidra shah
2016-11-22 12:34:28 UTC
Permalink
Does Jena have hasOntProperty() like we have hasOntClass()? In my project I
need something like if instance/individual has "this property value", do
some operation.

Thank you for your time.
Lorenz B.
2016-11-22 12:36:48 UTC
Permalink
You can use Individual::getPropertyValue, see [1]

[1]
https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/ontology/OntResource.html#getPropertyValue-org.apache.jena.rdf.model.Property-
Post by Sidra shah
Does Jena have hasOntProperty() like we have hasOntClass()? In my project I
need something like if instance/individual has "this property value", do
some operation.
Thank you for your time.
--
Lorenz BÃŒhmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
Sidra shah
2016-11-22 12:47:02 UTC
Permalink
Hello Lorenz thanks,

You mean something like this:

RDFNode Value =individual.getPropertyValue(myPropertyName);

if (Value=="PropertyValue")
//

On Tue, Nov 22, 2016 at 3:36 PM, Lorenz B. <
Post by Lorenz B.
You can use Individual::getPropertyValue, see [1]
[1]
https://jena.apache.org/documentation/javadoc/jena/
org/apache/jena/ontology/OntResource.html#getPropertyValue-org.apache.
jena.rdf.model.Property-
Post by Sidra shah
Does Jena have hasOntProperty() like we have hasOntClass()? In my
project I
Post by Sidra shah
need something like if instance/individual has "this property value", do
some operation.
Thank you for your time.
--
Lorenz BÃŒhmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
Lorenz B.
2016-11-22 12:59:05 UTC
Permalink
Post by Sidra shah
Hello Lorenz thanks,
RDFNode Value =individual.getPropertyValue(myPropertyName);
if (Value=="PropertyValue")
No, more the other case indeed such that don't have to "know" the value,
i.e.

if( Value == null) {

} else {

}
Post by Sidra shah
//
On Tue, Nov 22, 2016 at 3:36 PM, Lorenz B. <
Post by Lorenz B.
You can use Individual::getPropertyValue, see [1]
[1]
https://jena.apache.org/documentation/javadoc/jena/
org/apache/jena/ontology/OntResource.html#getPropertyValue-org.apache.
jena.rdf.model.Property-
Post by Sidra shah
Does Jena have hasOntProperty() like we have hasOntClass()? In my
project I
Post by Sidra shah
need something like if instance/individual has "this property value", do
some operation.
Thank you for your time.
--
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
Sidra shah
2016-11-22 13:12:05 UTC
Permalink
Lorenz, with regards,

Is it mandatory to use : if( Value == null)

I mean every property will have a value. In my case, the property supposed
to have three values so I need:

if (Value=="Value1")
//do this

if (Value=="Value2")
//do this
else
// do this

However, in general case, I want to ask if we have or expected to have a
null value, can we do some operation on it or just we display a message to
user that value is null?

if( Value == null)
JOptionPane.showMessageDialog(null, "Value is null");





On Tue, Nov 22, 2016 at 3:59 PM, Lorenz B. <
Post by Lorenz B.
Post by Sidra shah
Hello Lorenz thanks,
RDFNode Value =individual.getPropertyValue(myPropertyName);
if (Value=="PropertyValue")
No, more the other case indeed such that don't have to "know" the value,
i.e.
if( Value == null) {
} else {
}
Post by Sidra shah
//
On Tue, Nov 22, 2016 at 3:36 PM, Lorenz B. <
Post by Lorenz B.
You can use Individual::getPropertyValue, see [1]
[1]
https://jena.apache.org/documentation/javadoc/jena/
org/apache/jena/ontology/OntResource.html#getPropertyValue-org.apache.
jena.rdf.model.Property-
Post by Sidra shah
Does Jena have hasOntProperty() like we have hasOntClass()? In my
project I
Post by Sidra shah
need something like if instance/individual has "this property value",
do
Post by Sidra shah
Post by Lorenz B.
Post by Sidra shah
some operation.
Thank you for your time.
--
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.
2016-11-22 13:29:02 UTC
Permalink
Ok, I overlooked that you have the value given.
Post by Sidra shah
Lorenz, with regards,
Is it mandatory to use : if( Value == null)
No, not if you can ensure that there is always exactly one value.
Post by Sidra shah
I mean every property will have a value. In my case, the property supposed
if (Value=="Value1")
You have to use Java object equality instead.
Post by Sidra shah
//do this
if (Value=="Value2")
//do this
else
// do this
However, in general case, I want to ask if we have or expected to have a
null value, can we do some operation on it or just we display a message to
user that value is null?
if( Value == null)
JOptionPane.showMessageDialog(null, "Value is null");
You can't do anything on a NULL value - it's a Java NULL. In any case,
you should handle this case and give a warning as you suggested.
Post by Sidra shah
On Tue, Nov 22, 2016 at 3:59 PM, Lorenz B. <
Post by Lorenz B.
Post by Sidra shah
Hello Lorenz thanks,
RDFNode Value =individual.getPropertyValue(myPropertyName);
if (Value=="PropertyValue")
No, more the other case indeed such that don't have to "know" the value,
i.e.
if( Value == null) {
} else {
}
Post by Sidra shah
//
On Tue, Nov 22, 2016 at 3:36 PM, Lorenz B. <
Post by Lorenz B.
You can use Individual::getPropertyValue, see [1]
[1]
https://jena.apache.org/documentation/javadoc/jena/
org/apache/jena/ontology/OntResource.html#getPropertyValue-org.apache.
jena.rdf.model.Property-
Post by Sidra shah
Does Jena have hasOntProperty() like we have hasOntClass()? In my
project I
Post by Sidra shah
need something like if instance/individual has "this property value",
do
Post by Sidra shah
Post by Lorenz B.
Post by Sidra shah
some operation.
Thank you for your time.
--
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
Sidra shah
2016-11-22 13:34:42 UTC
Permalink
Thanks Lorenz for your guidance.

Best regards

On Tue, Nov 22, 2016 at 4:29 PM, Lorenz B. <
Post by Lorenz B.
Ok, I overlooked that you have the value given.
Post by Sidra shah
Lorenz, with regards,
Is it mandatory to use : if( Value == null)
No, not if you can ensure that there is always exactly one value.
Post by Sidra shah
I mean every property will have a value. In my case, the property
supposed
Post by Sidra shah
if (Value=="Value1")
You have to use Java object equality instead.
Post by Sidra shah
//do this
if (Value=="Value2")
//do this
else
// do this
However, in general case, I want to ask if we have or expected to have a
null value, can we do some operation on it or just we display a message
to
Post by Sidra shah
user that value is null?
if( Value == null)
JOptionPane.showMessageDialog(null, "Value is null");
You can't do anything on a NULL value - it's a Java NULL. In any case,
you should handle this case and give a warning as you suggested.
Post by Sidra shah
On Tue, Nov 22, 2016 at 3:59 PM, Lorenz B. <
Post by Lorenz B.
Post by Sidra shah
Hello Lorenz thanks,
RDFNode Value =individual.getPropertyValue(myPropertyName);
if (Value=="PropertyValue")
No, more the other case indeed such that don't have to "know" the value,
i.e.
if( Value == null) {
} else {
}
Post by Sidra shah
//
On Tue, Nov 22, 2016 at 3:36 PM, Lorenz B. <
Post by Lorenz B.
You can use Individual::getPropertyValue, see [1]
[1]
https://jena.apache.org/documentation/javadoc/jena/
org/apache/jena/ontology/OntResource.html#
getPropertyValue-org.apache.
Post by Sidra shah
Post by Lorenz B.
Post by Sidra shah
Post by Lorenz B.
jena.rdf.model.Property-
Post by Sidra shah
Does Jena have hasOntProperty() like we have hasOntClass()? In my
project I
Post by Sidra shah
need something like if instance/individual has "this property value",
do
Post by Sidra shah
Post by Lorenz B.
Post by Sidra shah
some operation.
Thank you for your time.
--
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
Continue reading on narkive:
Loading...