* @param cls
* @param target
*/
private IClass copyClass2(BClass src,IClass parent){
long time = System.currentTimeMillis();
IOntology target = parent.getOntology();
IClass dst = getClass2(src,parent);
// if no such resource, then we are fucked
if(dst == null)
return null;
// add superclasses if needed (avoid infinite loops)
for(IClass cls : src.getDirectSuperClasses()){
if(cls.getName().equals(parent.getName()) || cls.equals(src))
continue;
// add superclass
IClass p = getClass2((BClass)cls,target.getRoot());
if(p != null && !p.hasSuperClass(p))
dst.addSuperClass(p);
}
// remove root class as parent if it is not in source, but in destination
if(src.getDirectSuperClasses().length > 0 && dst.hasDirectSuperClass(target.getRoot()) && !src.hasDirectSuperClass(src.getOntology().getRoot())){
dst.removeSuperClass(target.getRoot());
}
// copy superficial stuff
for(String lbl: src.getLabels())
dst.addLabel(lbl);
for(String com: src.getComments())
dst.addComment(com);
if(src.getVersion() != null && dst.getVersion() != src.getVersion())
dst.addVersion(src.getVersion());
// copy properties values
for(IProperty sp : src.getProperties()){
// skip PartOf, and has_PART
if(HAS_PART.equals(sp.getName()) || PART_OF.equals(sp.getName()))
continue;
IProperty dp = target.getProperty(sp.getName());
// create unknown property for the first time
if(dp == null && !target.hasResource(sp.getName())){
dp = target.createProperty(sp.getName(),IProperty.ANNOTATION_DATATYPE);
dp.setRange(new String [0]);
}
// copy string values if not there
dst.setPropertyValues(dp,src.getPropertyValues(sp));