Ok,
I found a solution on my own - though it is awful:
If anyone has a better solution where I don't have to deal with slots
and don't have to use deprecated methods ... please let me know.
Chhers,
Michael
<snip>
AbstractProtegeReasoner protegeReasoner =
(AbstractProtegeReasoner)
ReasonerManager.getInstance().getProtegeReasoner(owlModel);
// Get all individuals of class Track
OWLNamedClass c_track = owlModel.getOWLNamedClass("j.0:Track");
Collection<OWLIndividual> tracks = c_track.getInstances();
// Iterate over all individuals of class Track
for (OWLIndividual track : tracks)
{
// Get all slots of current individual
Collection<Slot> slots = track.getOwnSlots();
// Iterate over all slots of current individual
for (Slot slot : slots)
{
// Check whether current slot is a transitive object
property
if (!slot.isSystem() && slot instanceof
OWLObjectProperty && ((OWLObjectProperty) slot).isTransitive())
{
OWLObjectProperty prop = (OWLObjectProperty) slot;
Collection<OWLIndividual> values;
try
{
// Now here you get the (transitive) property values
values =
protegeReasoner.getRelatedIndividuals(track, prop);
if (values != null && values.size() > 0)
{
// Get all "common" individuals of the specific
// property value of the current Track
individual
Collection<OWLIndividual> track_prop_values
= track.getPropertyValues(prop);
// Iterate over all property values as
// OWLIndividuals (including transitive ones)
for (OWLIndividual individual : values)
{
boolean exists = false;
// Iterate over all "common" individuals
of the
// specific property value of the
current Track
// individual
// set the "exist" flag if they are
already in
// the model
for (OWLIndividual t_individual :
track_prop_values)
{
if
(individual.getBrowserText().equals(t_individual.getBrowserText()))
{
exists = true;
break;
}
}
// If the relation to (transitive)
individual
// doesn't exist yet add it
if (!exists)
{
track.addPropertyValue(prop,
individual);
System.out.println("Added to "
+ track.getBrowserText() + " "
+ prop.getBrowserText() + " "
+ individual.getBrowserText());
}
}
}
}
catch (ProtegeReasonerException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
</snip>
Michael Lodemann schrieb:
> Hello,
>
> can anyone send me a piece of code how to persist inferred transitive
> property values in my model in order to store them permanently in the
> knowledge base?
>
> Thanks in advance,
> Michael
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owlInstructions for unsubscribing:
http://protege.stanford.edu/doc/faq.html#01a.03