// obtain a nice Java-conform name which has not yet been used
String propertyName = JavaNamingUtils.toBeanName(property,
domainClass.getUsedPropertyNames());
assert propertyName != null;
JProperty jprop = new JProperty(domainClass, propertyName, (URI)property.getResource());
// carry over the comment from RDF to Java, might be null
jprop.setComment(Utils.toJavaComment(property.getAllComment_asList()));
log.debug("PROPERTY Adding '" + jprop.getName() + "' to '" + domainClass.getName() + "'");
jprop.getJClass().getProperties().add(jprop);
// process range information
log.debug("PROPERTY checking ranges...");
for(Class range : property.getAllRange_asList()) {
log.debug("range is " + range);
jprop.addType(jm.getMapping(range.getResource()));
}
if(property.getAllRange_asList().size() == 0) {
// if no range is given, set to ontology root class (rdfs:Class or
// owl:Class)
jprop.addType(jm.getRoot());
}
// process cardinality constraints (convert this property to an OWL
// restriction)
OWL_Protege_NRL_Restriction restriction = (OWL_Protege_NRL_Restriction)property
.castTo(OWL_Protege_NRL_Restriction.class);
assert restriction != null;
Integer card = restriction.getCardinality();
Integer minCard = restriction.getMinCardinality();
Integer maxCard = restriction.getMaxCardinality();
int min = -1;
int max = -1;
if(minCard != null) {
min = minCard;
log.debug("Found minrestriction on " + property + " minCard = " + min);
} else if(card != null) {
log.debug("Found card.restriction on " + property + " card = " + min);
min = card;
}
jprop.setMinCardinality(min);
if(maxCard != null) {
max = maxCard;
log.debug("Found maxrestriction on " + property + " maxCard = " + max);
} else if(card != null) {
log.debug("Found card.restriction on " + property + " card = " + min);
max = card;
}
jprop.setMaxCardinality(max);
if(min != -1 || max != -1) {
domainClass.cardinalityexception = true;
log.debug("added card.exception in class " + domainClass.getName());
}