* @return {@link Individual} instance if there is a real already created one or there is no resources
* created for the specified CMSObject. If there is an ontology class created for the CMSObject,
* it returns <code>null</code>.
*/
public Individual createIndividualByCMSObject(CMSObject cmsObject, Resource klass) {
Individual ind = null;
try {
ind = getLooseIndividualByReference(cmsObject.getUniqueRef());
} catch (UnsupportedPolymorphismException e) {
log.warn("Another type of resource has been created for the CMS Object: {}",
cmsObject.getLocalname());
return null;
} catch (ConversionException e) {
log.warn("Another type of resource has been created for the CMS Object: {}",
cmsObject.getLocalname());
return null;
}
if (ind == null) {
String indURI = namingStrategy.getIndividualName(ontologyURI, cmsObject);
ind = ontModel.createIndividual(indURI, klass);
ind.addProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP, cmsObject.getUniqueRef());
return ind;
} else if (ind.isClass()) {
log.debug("Resource {} is already a class", ind.getURI());
return null;
} else {
return ind;
}